问题描述
我正在使用ElasticSearch,我有以下索引映射:
I am using ElasticSearch and I have the following index mapping:
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>"
}
}
}
}
}
如何让短语建议者返回扑热息痛药片:
How do I get the phrase suggestor to return "paracetamol tablets" at the moment it returns:
"suggest": {
"simple_phrase": [
{
"text": "paracetmo tabelts",
"offset": 0,
"length": 17,
"options": [
{
"text": "paracetmo tablets",
"highlighted": "paracetmo <em>tablets</em>",
"score": 0.24901225
}
]
}
]
我需要使用自定义分析器和字典吗?
Do I need to use a custom analyzer and a dictionary?
推荐答案
问题是max_errors:0.5,
参数。如果将其设置为 0.8
,则返回您的预期结果。我不能真正解释你为什么0.8工作,因为实际上0.5意味着50%的术语可以写错,这是你的使用,但不知何故与0.8工作。也许在弹性搜索用户组中查询该信息?
The problem is the "max_errors" : 0.5,
parameter. If you set it to 0.8
it returns your expected result. I can't really explain you why 0.8 works because actually 0.5 means 50% of the terms can be written wrong and that is your usecase but somehow it works with 0.8. Maybe ask with that information in the elasticsearch usergroup?
这篇关于弹性搜索 - 短语提示者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!