I encountered a strange issue, when a query fails depending on the position of a term and only then the length
filter is active (see below):
- works:
GET test/_search?filter_path=**.productNumber
{
"query": {
"match": {
"productNumber": {
"query": "abc def ghij 3d"
}
}
}
}
- fails
GET test/_search?filter_path=**.productNumber
{
"query": {
"match": {
"productNumber": {
"query": "abc def 3d ghij"
}
}
}
}
Exception:
"caused_by" : {
"type" : "array_index_out_of_bounds_exception",
"reason" : "Index 0 out of bounds for length 0"
}
ES versions tested: 7.5, 7.6
Index settings:
PUT test
{
"settings": {
"number_of_shards": "1",
"number_of_replicas": "0",
"analysis": {
"filter": {
"length_min_2": {
"type": "length",
"min": 2
},
"word_split_product_number": {
"type": "word_delimiter_graph",
"split_on_numerics": true,
"generate_number_parts": true,
"catenate_words": true,
"catenate_numbers": true,
"catenate_all": true,
"preserve_original": true
}
},
"analyzer": {
"word_split_product_number_analyzer": {
"filter": [
"lowercase",
"word_split_product_number",
"length_min_2"
],
"tokenizer": "standard"
}
}
}
},
"mappings": {
"properties": {
"productNumber": {
"type": "text",
"analyzer": "word_split_product_number_analyzer"
}
}
}
}
Test docs:
PUT test/_bulk
{"index":{}}
{"productNumber":"ABC-DEF-GHIJ-3A"}
{"index":{}}
{"productNumber":"ABC-DEF-GHIJ-3B"}
{"index":{}}
{"productNumber":"ABC-DEF-GHIJ-3C"}
{"index":{}}
{"productNumber":"ABC-DEF-GHIJ-3D"}