Skip to content

Commit

Permalink
add: meilisearch
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Apr 3, 2024
1 parent aec9818 commit 8be6a09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
18 changes: 9 additions & 9 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions gamewide/search/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

async def main():
config = Config()
print(config.meili_pw)
client = AsyncClient('http://85.10.200.219:7700', config.meili_pw, verify=False)
db_client = MongoDatabase(stats_db_connection=config.stats_mongodb, static_db_connection=config.static_mongodb)

pipeline = [{"$match": {"$nor": [{"members": {"$lt": 10}}, {"level": {"$lt": 3}}, {"capitalLeague": "Unranked"}]}}, {"$group": {"_id": "$tag"}}]
Expand Down Expand Up @@ -38,12 +36,11 @@ async def main():
logger.info(f"{len(docs_to_insert)} docs")

# An index is where the documents are stored.
index = client.index('players')

async def add_documents(documents):
headers = {"Authorization" : f"Bearer {config.meili_pw}"}
async with aiohttp.ClientSession() as session:
async with session.post('http://85.10.200.219:7700', headers=headers, json=documents) as response:
async with session.post('http://85.10.200.219:7700/indexes/players/documents', headers=headers, json=documents) as response:
if response.status == 202: # Meilisearch accepted the update
print("Documents added successfully")
else:
Expand Down

0 comments on commit 8be6a09

Please sign in to comment.