-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: translating facets values using taxonomies (#121)
fixes: #120
- Loading branch information
Showing
9 changed files
with
123 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Operations on taxonomies in Elastic Search""" | ||
|
||
from elasticsearch_dsl import Search | ||
from elasticsearch_dsl.query import Q | ||
|
||
from app.config import IndexConfig | ||
|
||
|
||
def get_taxonomy_names( | ||
items: list[tuple[str, str]], | ||
config: IndexConfig, | ||
) -> dict[tuple[str, str], dict[str, list[str]]]: | ||
"""Given a set of terms in different taxonomies, return their names""" | ||
filters = [] | ||
for id, taxonomy_name in items: | ||
# match one term | ||
filters.append(Q("term", id=id) & Q("term", taxonomy_name=taxonomy_name)) | ||
query = ( | ||
Search(index=config.taxonomy.index.name) | ||
.filter("bool", should=filters, minimum_should_match=1) | ||
.params(size=len(filters)) | ||
) | ||
return { | ||
(result.id, result.taxonomy_name): result.names.to_dict() | ||
for result in query.execute().hits | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters