Skip to content

Commit

Permalink
add ranking rules
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed May 27, 2023
1 parent d2cd6bd commit 1a594ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion searchgram/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self):
self.client = meilisearch.Client(MEILI_HOST, MEILI_PASS)
self.client.create_index("telegram", {"primaryKey": "ID"})
self.client.index("telegram").update_filterable_attributes(["chat.id", "chat.username", "chat.type"])
self.client.index("telegram").update_ranking_rules(
["timestamp:desc", "words", "typo", "proximity", "attribute", "sort", "exactness"]
)
self.client.index("telegram").update_sortable_attributes(["timestamp"])
except:
logging.critical("Failed to connect to MeiliSearch")
Expand Down Expand Up @@ -61,7 +64,7 @@ def upsert(self, message):
if self.check_ignore(message):
return
data = self.set_uid(message)
self.client.index("telegram").add_documents([data])
self.client.index("telegram").add_documents([data], primary_key="ID")

@staticmethod
def __clean_user(user: "str"):
Expand Down

0 comments on commit 1a594ca

Please sign in to comment.