Changeset View
Changeset View
Standalone View
Standalone View
swh/search/elasticsearch.py
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
def token_decode(page_token: str) -> Dict[bytes, Any]: | def token_decode(page_token: str) -> Dict[bytes, Any]: | ||||
"""Read the page_token | """Read the page_token | ||||
""" | """ | ||||
return msgpack.loads(base64.b64decode(page_token.encode()), raw=True) | return msgpack.loads(base64.b64decode(page_token.encode()), raw=True) | ||||
class ElasticSearch: | class ElasticSearch: | ||||
def __init__(self, hosts: List[str], indexes: Dict[str, Dict[str, str]]): | def __init__(self, hosts: List[str], indexes: Dict[str, Dict[str, str]] = {}): | ||||
self._backend = Elasticsearch(hosts=hosts) | self._backend = Elasticsearch(hosts=hosts) | ||||
# Merge current configuration with default values | # Merge current configuration with default values | ||||
origin_config = indexes.get("origin", {}) | origin_config = indexes.get("origin", {}) | ||||
self.origin_config = {**ORIGIN_DEFAULT_CONFIG, **origin_config} | self.origin_config = {**ORIGIN_DEFAULT_CONFIG, **origin_config} | ||||
def _get_origin_index(self) -> str: | def _get_origin_index(self) -> str: | ||||
return self.origin_config[INDEX_NAME_PARAM] | return self.origin_config[INDEX_NAME_PARAM] | ||||
▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines |