From 4d5485ef05f7ec5941052e032feb523a42ce83aa Mon Sep 17 00:00:00 2001
From: Magic <82341152+MagicTheDev@users.noreply.github.com>
Date: Tue, 2 Apr 2024 20:54:53 -0500
Subject: [PATCH] add: meilisearch
---
.idea/workspace.xml | 18 +++++++++---------
gamewide/search/track.py | 8 +++++---
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 22f8bce..b9c0f6d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -185,14 +185,6 @@
1706581825121
-
-
- 1706752185760
-
-
-
- 1706752185760
-
1711069041236
@@ -577,7 +569,15 @@
1712108265312
-
+
+
+ 1712108422059
+
+
+
+ 1712108422059
+
+
diff --git a/gamewide/search/track.py b/gamewide/search/track.py
index aff806f..9a3f946 100644
--- a/gamewide/search/track.py
+++ b/gamewide/search/track.py
@@ -1,6 +1,8 @@
from utility.classes import MongoDatabase
from meilisearch_python_sdk import AsyncClient
from utility.config import Config
+from loguru import logger
+
import asyncio
@@ -13,7 +15,7 @@ async def main():
all_tags = [x["_id"] for x in (await db_client.global_clans.aggregate(pipeline).to_list(length=None))]
bot_clan_tags = await db_client.clans_db.distinct("tag")
all_tags = list(set(all_tags + bot_clan_tags))
- print(f"{len(all_tags)} tags")
+ logger.info(f"{len(all_tags)} tags")
size_break = 100_000
all_tags = [all_tags[i:i + size_break] for i in range(0, len(all_tags), size_break)]
@@ -33,9 +35,9 @@ async def main():
{"$unset": ["_id"]}
]
docs_to_insert = await db_client.global_clans.aggregate(pipeline=pipeline).to_list(length=None)
- print(len(docs_to_insert), "docs")
+ logger.info(f"{len(docs_to_insert)} docs")
# An index is where the documents are stored.
index = client.index('players')
- await index.add_documents_in_batches(documents=docs_to_insert, batch_size=100_000, primary_key="id", compress=True)
+ await index.add_documents_in_batches(documents=docs_to_insert, batch_size=1_000, primary_key="id", compress=True)
await asyncio.sleep(15)