-
-
Notifications
You must be signed in to change notification settings - Fork 168
Phrase queries in Elasticsearch 6 #1261
Description
Hey all. I wanted to reach out about your efforts to migrate to Elasticsearch 6. I'm very interested in helping out.
Many of the phrase queries in the unit test fixtures of pelias/api fail because the match queries have a type: 'phrase' parameter that is no longer supported in Elasticsearch 6+. This has been replaced by the match_phrase query type.
The match_phrase query type does not support cutoff_frequency and operator parameters. However, these parameters are still supported in the match query type. The match query type no longer supports slop.
For an example, let's look at https://github.com/pelias/api/blob/master/test/unit/fixture/autocomplete_boundary_country.js. There are two possible ways to make it compatibile with ES 6.
diff --git a/test/unit/fixture/autocomplete_boundary_country.js b/test/unit/fixture/autocomplete_boundary_country.js
index 5da3698..2ad0df6 100644
--- a/test/unit/fixture/autocomplete_boundary_country.js
+++ b/test/unit/fixture/autocomplete_boundary_country.js
@@ -3,16 +3,14 @@ module.exports = {
'bool': {
'must': [{
'constant_score': {
- 'query': {
+ 'filter': {
'match': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
'cutoff_frequency': 0.01,
- 'type': 'phrase',
- 'operator': 'and',
- 'slop': 3
+ 'operator': 'and'
}
}
}diff --git a/test/unit/fixture/autocomplete_boundary_country.js b/test/unit/fixture/autocomplete_boundary_country.js
index 5da3698..6b1e87e 100644
--- a/test/unit/fixture/autocomplete_boundary_country.js
+++ b/test/unit/fixture/autocomplete_boundary_country.js
@@ -3,15 +3,12 @@ module.exports = {
'bool': {
'must': [{
'constant_score': {
- 'query': {
- 'match': {
+ 'filter': {
+ 'match_phrase': {
'name.default': {
'analyzer': 'peliasQueryPartialToken',
'boost': 100,
'query': 'test',
- 'cutoff_frequency': 0.01,
- 'type': 'phrase',
- 'operator': 'and',
'slop': 3
}
}
I'm not sure which is the preferred solution. So I'm reaching out for your thoughts.