Skip to content

Commit

Permalink
fix: remove fields arg from es.search
Browse files Browse the repository at this point in the history
  • Loading branch information
BeritJanssen committed Jan 15, 2025
1 parent 0f4b022 commit be501d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions backend/es/tests/test_named_entity_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def test_ner_search_view(es_ner_search_client, client):

def test_construct_ner_query():
viewset = NamedEntitySearchView()
fields = ['content:ner']
query = viewset.construct_named_entity_query(fields, 'my_identifier')
query = viewset.construct_named_entity_query('my_identifier')
expected = {
"bool": {
"must": {"term": {"id": "my_identifier"}},
Expand Down
6 changes: 3 additions & 3 deletions backend/es/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def get(self, request, *args, **kwargs):
client = elasticsearch(corpus_name)
index = get_index(corpus_name)
fields = self.find_named_entity_fields(client, index)
query = self.construct_named_entity_query(fields, document_id)
response = client.search(index=index, query=query, fields=fields)
query = self.construct_named_entity_query(document_id)
response = client.search(index=index, query=query)
results = hits(response)
annotations = {}
response = {}
Expand All @@ -139,7 +139,7 @@ def find_named_entity_fields(self, client, index: str) -> list[str]:
field_names = fields.keys()
return [name for name in field_names if name.endswith(':ner')]

def construct_named_entity_query(self, fields: list[str], document_id: str) -> dict:
def construct_named_entity_query(self, document_id: str) -> dict:
"""construct a query in which the document_id is obligatory, and any of the :ner-kw fields is present"""
return {
"bool": {
Expand Down

0 comments on commit be501d7

Please sign in to comment.