0

我目前正在尝试使用 elasticsearch 的新自动建议(版本 0.90)。它实际上对我很有用,但我注意到所有建议结果都以小写形式返回。我正在尝试为德语网站实现自动建议,如果您只收到小写建议,这可能会让德语用户感到非常困惑,因为名词总是用德语大写。如果将建议保存在文档中,是否有可能获得建议?

例子:

// 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
    }]
  }]
}
4

1 回答 1

1

您的german分析仪正在执行小写,您可以像这样测试它:

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

尝试在不同的分析器上执行自动完成?

于 2013-06-20T12:56:25.210 回答