mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-18 17:14:39 -04:00
Add config for search backend
This commit is contained in:
parent
5f6673c72c
commit
c2c01af3ad
3 changed files with 23 additions and 13 deletions
|
@ -3,17 +3,18 @@ from typing import List
|
|||
from sonic import IngestClient, SearchClient
|
||||
|
||||
from archivebox.util import enforce_types
|
||||
from archivebox.config import SEARCH_BACKEND_HOST_NAME, SEARCH_BACKEND_PORT, SEARCH_BACKEND_PASSWORD, SONIC_BUCKET, SONIC_COLLECTION
|
||||
|
||||
|
||||
@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:
|
||||
with IngestClient(SEARCH_BACKEND_HOST_NAME, SEARCH_BACKEND_PORT, SEARCH_BACKEND_PASSWORD) as ingestcl:
|
||||
for text in texts:
|
||||
ingestcl.push("archivebox", "snapshots", snapshot_id, str(text))
|
||||
ingestcl.push(SONIC_BUCKET, SONIC_COLLECTION, 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)
|
||||
with SearchClient(SEARCH_BACKEND_HOST_NAME, SEARCH_BACKEND_PORT, SEARCH_BACKEND_PASSWORD) as querycl:
|
||||
snap_ids = querycl.query(SONIC_BUCKET, SONIC_COLLECTION, text)
|
||||
return snap_ids
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue