mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-24 19:54:25 -04:00
Implement backend architecture for search engines
This commit is contained in:
parent
b1f70b2197
commit
5f6673c72c
4 changed files with 69 additions and 35 deletions
19
archivebox/search/backends/sonic.py
Normal file
19
archivebox/search/backends/sonic.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from typing import List
|
||||
|
||||
from sonic import IngestClient, SearchClient
|
||||
|
||||
from archivebox.util import enforce_types
|
||||
|
||||
@enforce_types
|
||||
def index(snapshot_id: str, texts: List[str]):
|
||||
# TODO add variables to localhost, port, password, bucket, collection
|
||||
with IngestClient("localhost", 1491, "SecretPassword") as ingestcl:
|
||||
for text in texts:
|
||||
ingestcl.push("archivebox", "snapshots", snapshot_id, str(text))
|
||||
|
||||
@enforce_types
|
||||
def search(text: str) -> List:
|
||||
with SearchClient("localhost", 1491, "SecretPassword") as querycl:
|
||||
snap_ids = querycl.query("archivebox", "snapshots", text)
|
||||
return snap_ids
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue