Skip to content

Commit

Permalink
fix(es visitor): Removed unnecessary checking for bai_fieldnames
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Vagliano

ref: cern-sis/issues-inspire#616
  • Loading branch information
Lorenzovagliano committed Dec 12, 2024
1 parent 96d2486 commit 8ba68a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inspire_query_parser/visitors/elastic_search_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def visit_exact_match_value(self, node, fieldnames=None):
else:
exact_match_queries = [
{'match_phrase': {field: node.value}}
for field in (bai_fieldnames or fieldnames)
for field in (fieldnames)
]
query = wrap_queries_in_bool_clauses_if_more_than_one(
exact_match_queries, use_must_clause=False
Expand Down
24 changes: 24 additions & 0 deletions tests/test_elastic_search_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,30 @@ def test_elastic_search_visitor_PDG_keyword():
assert generated_es_query == expected_es_query


def test_elastic_search_visitor_PDG_keyword_with_dot_character():
query_str = 'keyword "S044.a"'
expected_es_query = {
"match_phrase": {
"keywords.value": "S044.a",
}
}

generated_es_query = _parse_query(query_str)
assert generated_es_query == expected_es_query


def test_elastic_search_visitor_PDG_keyword_with_dot_digit():
query_str = 'keyword "S044.4"'
expected_es_query = {
"match_phrase": {
"keywords.value": "S044.4",
}
}

generated_es_query = _parse_query(query_str)
assert generated_es_query == expected_es_query


def test_nested_query_author_exact_match_affiliation():
query_string = 'aff "Warsaw U. of Tech."'
expected_es_query = {
Expand Down

0 comments on commit 8ba68a0

Please sign in to comment.