Commit 1f28f1d7 authored by Carina Antunes's avatar Carina Antunes
Browse files

[SEARCH-69] Multifields type search parameter

parent cdf2ab15
......@@ -99,12 +99,16 @@ def search_factory(self, search: RecordCERNSearch, query_parser=None):
def _csas_query_parser(qstr=None):
"""Parse with Q() from elasticsearch_dsl."""
default_multifields_type = "best_fields"
multifields_type = request.args.get('type', default_multifields_type)
if qstr:
return Q(
'query_string',
query=qstr,
default_field='_data.*',
rewrite="scoring_boolean" # calculates score for wildcards queries
rewrite="scoring_boolean", # calculates score for wildcards queries
type=multifields_type
)
return Q()
......
......@@ -90,7 +90,7 @@ def test_testclient(app, client, user):
resp = client.get(
'/records/',
headers=get_headers(),
query_string={'q': 'CernSearch', 'explain': 'true', 'highlight': '*'}
query_string={'q': 'CernSearch', 'explain': 'true', 'highlight': '*', 'type': 'cross_fields'}
)
assert resp.status_code == HTTPStatus.OK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment