Changeset View
Changeset View
Standalone View
Standalone View
swh/search/elasticsearch.py
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | def initialize(self) -> None: | ||||
if not self._backend.indices.exists_alias(self._get_origin_write_alias()): | if not self._backend.indices.exists_alias(self._get_origin_write_alias()): | ||||
self._backend.indices.put_alias( | self._backend.indices.put_alias( | ||||
index=self._get_origin_index(), name=self._get_origin_write_alias() | index=self._get_origin_index(), name=self._get_origin_write_alias() | ||||
) | ) | ||||
self._backend.indices.put_mapping( | self._backend.indices.put_mapping( | ||||
index=self._get_origin_index(), | index=self._get_origin_index(), | ||||
body={ | body={ | ||||
"dynamic_templates": [ | |||||
{ | |||||
"booleans_as_string": { | |||||
# All fields stored as string in the metadata | |||||
# even the booleans | |||||
"match_mapping_type": "boolean", | |||||
"path_match": "intrinsic_metadata.*", | |||||
"mapping": {"type": "keyword"}, | |||||
} | |||||
} | |||||
], | |||||
"date_detection": False, | "date_detection": False, | ||||
"properties": { | "properties": { | ||||
# sha1 of the URL; used as the document id | # sha1 of the URL; used as the document id | ||||
"sha1": {"type": "keyword", "doc_values": True,}, | "sha1": {"type": "keyword", "doc_values": True,}, | ||||
# Used both to search URLs, and as the result to return | # Used both to search URLs, and as the result to return | ||||
# as a response to queries | # as a response to queries | ||||
"url": { | "url": { | ||||
"type": "text", | "type": "text", | ||||
▲ Show 20 Lines • Show All 235 Lines • Show Last 20 Lines |