I have a tricky problem: If I search for a prefix that ends with a partial number, the search does not return any results.
ES version: 6.1 for .NET
Index settings
{ "document_idx": { "settings": { "index": { "provided_name": "document_idx", "analysis": { "filter": { "FoldingTokenFilter": { "type": "asciifolding", "preserve_original": "true" } }, "analyzer": { "FullTextAnalyzer": { "filter": [ "lowercase", "FoldingTokenFilter" ], "type": "custom", "tokenizer": "standard" } } } } } } }
Index mapping
{ "document_idx": { "mappings": { "documentmapping": { "_source": { "enabled": false }, "properties": { "fullTextField": { "type": "text", "norms": false, "analyzer": "FullTextAnalyzer" } } } } } }
The field value, that gets in at index time
Document - ABC-123-2019, DE100006, 520 USD
The search query that gets the wanted hit (last number is an exact match)
GET document_idx/_search? { "query": { "bool": { "must": [ { "match_phrase_prefix": { "fullTextField": { "query": "ABC-123-2019" } } } ], "minimum_should_match": 0 } } }
The search query that DOES NOT get me any hits (last number is partial)
GET document_idx/_search? { "query": { "bool": { "must": [ { "match_phrase_prefix": { "fullTextField": { "query": "ABC-123-201" } } } ], "minimum_should_match": 0 } } }
Another NOT WORKING query, that does not get me any hits (first word is partial) - I don't know if this should work
GET document_idx/_search? { "query": { "bool": { "must": [ { "match_phrase_prefix": { "fullTextField": { "query": "AB 123-2019" } } } ], "minimum_should_match": 0 } } }
Can anyone please explain me why elastic search works as observed.
Does it have to do something with the index time tokens of type <NUM>
?
Because if the last word is not numeric, than the partial search works like a charm.
And please, do not tell me to use Ngram or similar. fullTextField is enormous. And I need to start searching from a single character input on...