ElasticSearch - Phrase Suggestor

时间:2015-08-14 13:19:48

标签: elasticsearch

我正在使用ElasticSearch,我有以下索引映射:

post  /my_index
{ 
  "mappings": {
    "medical_terms": {
      "properties": {
        "terms": {
          "type":     "string"
        }
      }
    }
  }
} 

PUT my_index/medical_terms/1
{
  "term":   "Paracetamol tablets"
}

POST /my_index/_search?search_type=count
{
  "suggest" : {
    "text" : "paracetmo tabelts",
    "simple_phrase" : {
      "phrase" : {
        "field" : "term",
        "size" : 1,
        "real_word_error_likelihood" : 0.95,
        "max_errors" : 0.5,
        "gram_size" : 2,
        "highlight": {
          "pre_tag": "<em>",
          "post_tag": "</em>"
        }
      }
    }
  }
}

如何获得短语建议者返回&#34;对乙酰氨基酚片剂&#34;在它返回的那一刻:

"suggest": {
  "simple_phrase": [
     {
        "text": "paracetmo tabelts",
        "offset": 0,
        "length": 17,
        "options": [
           {
              "text": "paracetmo tablets",
              "highlighted": "paracetmo <em>tablets</em>",
              "score": 0.24901225
           }
        ]
     }
  ]

我是否需要使用自定义分析器和字典?

1 个答案:

答案 0 :(得分:4)

问题是0.8参数。如果将其设置为Error saving field,则会返回预期结果。我无法真正解释为什么0.8有效,因为实际上0.5意味着50%的术语可能写错了,这就是你的用例但不知何故它适用于0.8。也许在elasticsearch用户组中询问这些信息?