Upgrade meilisearch to v1.56.2

This commit is contained in:
Tanner
2026-11-12 20:03:38 +00:00
parent f372b0e914
commit db6e41177b
3 changed files with 27 additions and 11 deletions
+8 -8
View File
@@ -25,17 +25,17 @@ def meili_api(method, route, json=None, params=None, parse_json=True):
logging.error('Problem with MeiliSearch api route: %s: %s', route, str(e))
return False
def create_index():
json = dict(uid='qotnews', primaryKey='id')
def create_index(index_uid='qotnews'):
json = dict(uid=index_uid, primaryKey='id')
return meili_api(requests.post, 'indexes', json=json)
def update_settings():
def update_settings(index_uid='qotnews'):
json = {
'rankingRules': ['typo', 'words', 'proximity', 'date:desc', 'exactness'],
'searchableAttributes': ['title', 'url', 'author'],
'displayedAttributes': ['id', 'ref', 'source', 'author', 'author_link', 'score', 'date', 'title', 'link', 'url', 'num_comments'],
}
return meili_api(requests.post, 'indexes/qotnews/settings', json=json)
return meili_api(requests.patch, 'indexes/{}/settings'.format(index_uid), json=json)
def init():
if not SEARCH_ENABLED:
@@ -44,14 +44,14 @@ def init():
print(create_index())
update_settings()
def put_story(story):
def put_story(story, index_uid='qotnews'):
if not SEARCH_ENABLED: return
return meili_api(requests.post, 'indexes/qotnews/documents', [story])
return meili_api(requests.post, 'indexes/{}/documents'.format(index_uid), [story])
def search(q):
def search(q, index_uid='qotnews'):
if not SEARCH_ENABLED: return []
json = dict(q=q, limit=settings.FEED_LENGTH)
r = meili_api(requests.post, 'indexes/qotnews/search', json=json, parse_json=False)
r = meili_api(requests.post, 'indexes/{}/search'.format(index_uid), json=json, parse_json=False)
return r
if __name__ == '__main__':