Elasticsearch version: 5,2
Plugins installed: []
JVM version:
OS version: official docker image
Description of the problem including expected versus actual behavior:
moving to ES5 from 2.4 I noticed a weir dbehaviour in the new suggester.
I have a completion field like this:
{"input"=>["[2017] foo 9", "2016 bar 8", "o'shea v ireland", "o'shea ireland", "ireland"]}
Then I try a query for "o'sh" or "ire"and it works, but it doesn't works for "[2017" or "2016".
I tried different combination and I never get results when I try to query a number.
This is the query:
{
"_source": [field1, field2],
suggest: {
suggestion: {
prefix: "MYTEXT",
completion: {
field: "mysuggest",
size: 5,
fuzzy: true
}
}
}
}
Steps to reproduce:
That's because the simple analyzer "removes" the numbers and square brackets from your input.
Just add a for example whitespace analyzer for your suggest field.
thanks @taitaro
I understand why stop words and brackets are removed, but I don't understadn why number, in particular in suggestions
AS @taitaro said, it's because the completion suggester uses the [simple analyzer])(https://www.elastic.co/guide/en/elasticsearch/reference/5.2/analysis-simple-analyzer.html) by default. You can change it to use a different analyzer
I'm having the same issue when I try to search a number
and it's not working with whitespace analyzer
{"type":"mapper_parsing_exception","reason":"analyzer on completion field [name_suggest] must be set when search_analyzer is set"}],"type":"mapper_parsing_exception","reason":"analyzer on completion field [name_suggest] must be set when search_analyzer is set"}
With elastic 7.1
Update:
Just need to be added to the mapping "analyzer": "standard"
{
"sample": {
"properties": {
"words-suggester": {
"type":"completion",
"analyzer": "standard"
}
}
}
}
Most helpful comment
That's because the simple analyzer "removes" the numbers and square brackets from your input.
Just add a for example whitespace analyzer for your suggest field.