Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
webservices
cern-search
cern-search-rest-api
Commits
1f28f1d7
Commit
1f28f1d7
authored
Apr 07, 2020
by
Carina Antunes
Browse files
[
SEARCH-69
] Multifields type search parameter
parent
cdf2ab15
Changes
2
Hide whitespace changes
Inline
Side-by-side
cern_search_rest_api/modules/cernsearch/search.py
View file @
1f28f1d7
...
...
@@ -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
()
...
...
tests/api/test_search.py
View file @
1f28f1d7
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment