ElasticSearch 5.5.0 query regression?


#1

I index the following document on ElasticSearch 5.5.0:

{
	"_index": "fts-english",
	"_type": "Document",
	"_id": "black1",
	"_version": 1,
	"_score": 1,
	"_source": {
		"streamId": 1,
		"WordB": "Cat",
		"WordC": "Dog",
		"WordA": "Black",
		"language": "english",
		"message": "Black Cat",
		"doc_id": "black1"
	}
}

The mapping is:

"mappings": {
	"Document": {
		"dynamic_templates": [{
				"not_analyzed_fields": {
					"match_pattern": "regex",
					"mapping": {
						"include_in_all": false,
						"index": false,
						"type": "text"
					},
					"match": "(language|doc_id)"
				}
			}
		],
		"_all": {
			"search_analyzer": "default_search",
			"analyzer": "default"
		},
		"properties": {
			"streamId": {
				"type": "long"
			},
			"WordB": {
				"search_analyzer": "default_search",
				"analyzer": "default",
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"WordC": {
				"search_analyzer": "default_search",
				"analyzer": "default",
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"WordA": {
				"search_analyzer": "default_search",
				"analyzer": "default",
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"language": {
				"search_analyzer": "default_search",
				"include_in_all": false,
				"analyzer": "default",
				"index": false,
				"type": "text"
			},
			"message": {
				"search_analyzer": "default_search",
				"analyzer": "default",
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"doc_id": {
				"search_analyzer": "default_search",
				"include_in_all": false,
				"analyzer": "default",
				"index": false,
				"type": "text"
			}
		}
	},
	"system": {
		"_all": {
			"search_analyzer": "default_search",
			"analyzer": "default"
		},
		"properties": {
			"system_message": {
				"search_analyzer": "default_search",
				"analyzer": "default",
				"type": "text",
				"fields": {
					"keyword": {
						"ignore_above": 256,
						"type": "keyword"
					}
				}
			},
			"ftsIndexVersion": {
				"type": "long"
			}
		}
	}
}

Then I run an exact phrase query for "black cat"

{
	"size": 50,
	"query": {
		"bool": {
			"should": [{
					"multi_match": {
						"query": "Black Cat",
						"fields": [
							"mess*^1.0"
						],
						"type": "phrase",
						"operator": "OR",
						"analyzer": "default_phrase_analyzer",
						"slop": 0,
						"prefix_length": 0,
						"max_expansions": 50,
						"lenient": false,
						"zero_terms_query": "NONE",
						"boost": 1.0
					}
				}
			],
			"disable_coord": false,
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	},
	"post_filter": {
		"bool": {
			"filter": [{
					"term": {
						"_type": {
							"value": "Document",
							"boost": 1.0
						}
					}
				}
			],
			"disable_coord": false,
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	},
	"highlight": {
		"pre_tags": [
			"<b>"
		],
		"post_tags": [
			"</b>"
		],
		"fragment_size": 0,
		"number_of_fragments": 0,
		"require_field_match": true,
		"fields": {
			"Twee*": {},
			"user*": {},
			"mess*": {},
			"Word*": {}
		}
	}
}

and I get the following error:

[2017-07-30T08:37:45,600][DEBUG][o.e.a.s.TransportSearchAction] [RvqdrEn] [59179] Failed to execute query phase
org.elasticsearch.transport.RemoteTransportException: [RvqdrEn][127.0.0.1:9300][indices:data/read/search[phase/query/id]]
Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException: Query Failed [Failed to execute main query]
        at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:414) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:108) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:349) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.action.search.SearchTransportService$7.messageReceived(SearchTransportService.java:340) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.action.search.SearchTransportService$7.messageReceived(SearchTransportService.java:337) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:644) [elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) [elasticsearch-5.5.0.jar:5.5.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.5.0.jar:5.5.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: java.lang.IllegalStateException: field "message.keyword" was indexed without position data; cannot run PhraseQuery (phrase=message.keyword:"black cat")
        at org.apache.lucene.search.PhraseQuery$PhraseWeight.scorer(PhraseQuery.java:411) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]
        at org.apache.lucene.search.DisjunctionMaxQuery$DisjunctionMaxWeight.scorer(DisjunctionMaxQuery.java:145) ~[lucene-core-6.6.0.jar:6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:29:46]

This works perfectly on Elastic Search 2.2.0, where the mapping is based on "string" field type rather than "text".
Trying to search for a solution on the web got nowhere.


(David Pilato) #2

The problem here is that you have a .keyword subfield which I guess has a keyword type. But you selected it with mess*.

You need to remove that field in your mapping or don't use the wildcard.


#3

Thank you very much, David!
This indeed was the problem, caused by the new "text" field type that replaced "string" type and contains the internal field "keyword".


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.