所有格_英语词干分析器在Elasticsearch中的使用 [英] Using of possessive_english stemmer in Elasticsearch
问题描述
我具有以下分析设置:
"settings" : {
"index" : {
"creation_date" : "1469213620697",
"analysis" : {
"filter" : {
"stem_possessive_filter" : {
"name" : "possessive_english",
"type" : "stemmer"
}
},
"analyzer" : {
"stem_analyzer" : {
"filter" : [ "standard", "lowercase", "stem_possessive_filter" ],
"tokenizer" : "standard"
}
}
},
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "VQgaaZquQUOqKNYxGPH7cg",
"version" : {
"created" : "2020199"
}
}
},
每个字符串类型的字段都具有以下映射:
Every field of string type has the following mapping:
"field_name" : {
"type" : "string",
"analyzer" : "stem_analyzer",
"search_analyzer" : "standard"
}
我希望能够写阿尔茨海默氏症中的痴呆症 或阿尔茨海默氏症中的 痴呆症 。结果,我想在阿尔茨海默氏症中得到 痴呆症。 。
I want to be able to write dementia in alzheimer or dementia in alzheimer's phrase. And as a result, I want to get Dementia in Alzheimer's ....
多匹配查询在以下情况下不起作用
Multi match query doesn't work if the possession is not used:
{'query':{'multi_match':{'query':老年痴呆症,'类型':'phrase','fields':['_all']}}}
但如果使用了所有物,则可以使用:
But it works if the possession is used:
{'query':{'multi_match':{'query':老年痴呆症中的痴呆症,'type':'短语','字段:['_ all']}}}
另一方面,布尔查询在不使用所有物的情况下有效:
On the other hand, Bool query works if the possession is not used:
{'query':{'bool':{'must':[{'match_phrase':{'Diagnosis':老年痴呆症}}]}}} }
但如果拥有是
{'query':{'bool':{'must':[{'match_phrase':{'Diagnosis':老年痴呆症的痴呆症}}}}}
如何使以上所有查询正常工作?
How to make all the queries above work?
-更新-
如果添加 stem_analyzer $,布尔查询将起作用c $ c>在查询中。因此,您可以在搜索过程中使用它。无论有没有占有,我都会得到一个短语的结果。
mybody = {'query':{'bool':{'must':[{'match_phrase':{'Diagnosis':{'query':老年痴呆症的痴呆,' Analyzer':'stem_analyzer'}}}}}}}
The bool query works if you add stem_analyzer
in the query. Thus you use it during search. And I get results for a phrase both with and without possession.
mybody = {'query': {'bool': {'must': [{'match_phrase': {'Diagnosis': {'query': "dementia in alzheimer's", 'analyzer': 'stem_analyzer'}}}]}}}
但是,如果添加分析器,多重匹配查询将完全停止工作。无论是否拥有,短语都不会得到任何结果。
{'query':{'multi_match':{'query':老年痴呆症的痴呆症,'type':'短语','analyzer':'stem_analyzer','fields' :['_all']}}}
But, the multi match query stops working at all if you add analyzer. I don't get any results for a phrase both with and without possession.
{'query': {'multi_match': {'query': "dementia in alzheimer's", 'type': 'phrase', 'analyzer': 'stem_analyzer', 'fields': ['_all']}}}
为什么分析器不能用于多重匹配查询?
Why the analyzer doesn't work for the multi match query?
推荐答案
短语
类型不适用于词干分析器进行多重匹配查询。但是 phrase_prefix
类型有效。坦白说,我不知道为什么。 文档。
The phrase
type doesn't work with stem analyzer for the multi match query. But phrase_prefix
type works. Frankly speaking, I don't know why. There is no hint about it in the documentation.
因此,以下两个多重匹配查询为我返回了相同的结果:
So, the following two multi match queries return the same results for me:
{'query':{'multi_match':{'query':老年痴呆症,'type':'phrase_prefix','analyzer':'stem_analyzer','fields':['_all']}}}
{'query':{'multi_match':{'query':老年痴呆症,类型':'phrase_prefix','analyzer':'stem_analyzer','fields':['_all']}}}
在布尔查询 match_phrase
与词干分析器配合使用。
以下两个查询返回相同的结果:
In the boolean query, match_phrase
works with stem analyzer.
The following two queries return the same results:
{'query':{'bool':{'must':[ {'match_phrase':{'Diagnosis':{'query':老年痴呆症, analyzer:'stem_analyzer'}}}}}}}
{'query':{'bool':{'must':[{'match_phrase':{'Diagnosis':{'query':老年痴呆症的痴呆症, 'analyzer':'stem_analyzer'}}}]}}}
这篇关于所有格_英语词干分析器在Elasticsearch中的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!