Commit f7971fb9 authored by Samuel Trégouët's avatar Samuel Trégouët
Browse files

[es6] remove `_all` field in search_helpers

this magic field does not exist anymore with elasticsearch 6
use computed field which it is named `alltext` by convention
parent 1d0ff3bd0daf
...@@ -37,7 +37,7 @@ def compose_search(search, query=None, fields=(), ...@@ -37,7 +37,7 @@ def compose_search(search, query=None, fields=(),
query: query:
text of the query to be composed (can contain quotes) text of the query to be composed (can contain quotes)
fields: fields:
restrict and boost search on certain fields eg. ('title^2', '_all') restrict and boost search on certain fields eg. ('title^2', 'alltext')
fuzzy: fuzzy:
add a fuzzy search element to part of the query generated add a fuzzy search element to part of the query generated
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
...@@ -73,12 +73,12 @@ def compose_search(search, query=None, fields=(), ...@@ -73,12 +73,12 @@ def compose_search(search, query=None, fields=(),
# highfrequency/lowfrequency query # highfrequency/lowfrequency query
# https://www.elastic.co/blog/stop-stopping-stop-words-a-look-at-common-terms-query # https://www.elastic.co/blog/stop-stopping-stop-words-a-look-at-common-terms-query
if common: if common:
common_query = dsl_query.Common(_all={"query": query, common_query = dsl_query.Common(alltext={"query": query,
"cutoff_frequency": cutoff_frequency, "cutoff_frequency": cutoff_frequency,
"low_freq_operator": "and", "low_freq_operator": "and",
"minimum_should_match": { "minimum_should_match": {
"high_freq": "70%" "high_freq": "70%"
}}) }})
should.append(common_query) should.append(common_query)
elements = query.split() elements = query.split()
...@@ -97,7 +97,7 @@ def compose_search(search, query=None, fields=(), ...@@ -97,7 +97,7 @@ def compose_search(search, query=None, fields=(),
else: else:
if fuzzy: if fuzzy:
should.append(dsl_query.Fuzzy(_all=element)) should.append(dsl_query.Fuzzy(alltext=element))
bool_query = dsl_query.Bool(must=must, bool_query = dsl_query.Bool(must=must,
must_not=must_not, must_not=must_not,
should=should, should=should,
......
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