Skip to content

Commit

Permalink
query
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Nov 18, 2023
1 parent 2cf5b36 commit a3458eb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ services:
- ./sg_data/mongodb:/data/db
logging:
driver: none
ports:
- "127.0.0.1:27017:27017"
2 changes: 2 additions & 0 deletions searchgram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from config import ENGINE

if ENGINE == "meili":
print("Using MeiliSearch as search engine")
from meili import SearchEngine
elif ENGINE == "mongo":
print("Using MongoDB as search engine")
from mongo import SearchEngine
8 changes: 5 additions & 3 deletions searchgram/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ class SearchEngine(BasicSearchEngine):
def __init__(self):
self.client = pymongo.MongoClient(host=MONGO_HOST, connect=False, connectTimeoutMS=5000, serverSelectionTimeoutMS=5000)
self.db = self.client["telegram"]
self.col = self.db["chat"]
self.history = self.db["history"]
self.chat = self.db["chat"]

def __del__(self):
self.client.close()

def upsert(self, message):
pass
if self.check_ignore(message):
return
data = self.set_uid(message)
self.chat.update_one({"ID": data["ID"]}, {"$set": data}, upsert=True)

def search(self, keyword, _type=None, user=None, page=1, mode=None):
pass
Expand Down

0 comments on commit a3458eb

Please sign in to comment.