Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es visitor): Removed unnecessary checking for bai_fieldnames #165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
54 changes: 54 additions & 0 deletions tests/test_elastic_search_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,60 @@ def test_elastic_search_visitor_PDG_keyword():
assert generated_es_query == expected_es_query


def test_elastic_search_visitor_PDG_keyword_with_dot_character():
Lorenzovagliano marked this conversation as resolved.
Show resolved Hide resolved
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_elastic_search_visitor_PDG_keyword_with_dot_character_no_quotes():
query_str = 'keyword:S044.a'
expected_es_query = {
"match": {
"keywords.value": {
"query": "S044.a",
"operator": "and"
}
}
}

generated_es_query = _parse_query(query_str)
assert generated_es_query == expected_es_query


def test_elastic_search_visitor_PDG_keyword_with_dot_digit_no_quotes():
query_str = 'keyword:S044.4'
expected_es_query = {
"match": {
"keywords.value": {
"query": "S044.4",
"operator": "and"
}
}
}

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
Loading