Question

I am currently experimenting with the new autosuggestion from elasticsearch (verson 0.90). It actually works great for me but I noticed that all the suggestion results are coming back in lowercase. I am trying to implement the autosuggestion for a german website and it can be quite confusing for german users if you get only lowercase suggestions because Nouns are always written in Upper Case in German. Is there any possibility to get the suggestion in the case in which it is saved in the documents?

Example:

// I have this document in my index autosuggestion type staedte
{
  _index: autosuggest
  _type: staedte
  _id: 11a40GY_QKaXbFT7RA51qA
  _score: 1
  _source: {
    staedte: {
      name: Berlin
    }
  }
}

// The following Request return the name of the city in lowercase

// Request
curl -XPOST 'http://localhost:9200/_suggest/' -d '
{
  "my-suggestion": {
    "text": "berlion",
    "term": {
      "field": "name",
      "analyzer": "german",
      "suggest_mode": "always"
    }
  }
}'

// Result
{
  {
  _shards: {
    total: 5
    successful: 5
    failed: 0
  }
  my-suggestion: [{
    text: berlion
    offset: 0
    length: 7
    options: [{
      text: berlin
      score: 0.8333333
      freq: 1
    }]
  }]
}
Was it helpful?

Solution

Your german analyzer is performing a lowercase, you can test it like this:

curl 'localhost:9200/autosuggest/_analyze?pretty=1&analyzer=german' -d 'berlion'

Try to performe the autocomplete on a different analyzer maybe?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top