2015-08-14 46 views
2

我使用ElasticSearch和我有以下指數映射:ElasticSearch - 詞組SUGGESTOR

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

我如何獲得這句話建議器在它返回的時刻返回「撲熱息痛片」:

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

我需要使用自定義分析器和字典嗎?

回答

1

問題是"max_errors" : 0.5,參數。如果您將其設置爲0.8,它會返回您的預期結果。我無法真正解釋你爲什麼0.8工作,因爲實際上0.5意味着50%的術語可能會寫錯,那是你的用例,但不知何故它可以與0.8一起工作。也許在elasticsearch用戶組中詢問這些信息?