Elasticsearch: completion Suggester not working with numbers in ES5.2

Created on 8 Feb 2017  路  5Comments  路  Source: elastic/elasticsearch

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:

  1. index a docuent with a completion field
  2. do a suggester query with a number as a query

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.

All 5 comments

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" } } } }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brwe picture brwe  路  3Comments

rpalsaxena picture rpalsaxena  路  3Comments

ttaranov picture ttaranov  路  3Comments

clintongormley picture clintongormley  路  3Comments

abrahamduran picture abrahamduran  路  3Comments