【发布时间】:2021-02-11 19:03:35
【问题描述】:
我的用例是在基于模糊和前缀匹配检索的字段中突出显示多个短语/单词。为此,我目前使用 span_near 来处理短语,并使用 span_multi 来允许在我的短语术语中使用模糊性。我还需要使用 prefix_length 所以模糊只允许前缀匹配后的字符,但 span_multi 不允许超过一个多词查询。有没有其他方法可以做到这一点?
"query":{
"bool":{
"should":[{
"span_near": {
"clauses": [
{
"span_multi": {
"match": {
"fuzzy": {
"comment": {
"fuzziness": "5",
"value": "Beata"
}
}
}
}
},
{
"span_multi": {
"match": {
"fuzzy": {
"comment": {
"fuzziness": "5",
"value": "Rosenane"
}
}
}
}
}
],
"in_order": False,
}},{
"span_near": {
"clauses": [
{
"span_multi": {
"match": {
"fuzzy": {
"comment": {
"fuzziness": "5",
"value": "Christna"
}
}
}
}
}
],
"in_order": False,
}}]
}
},
"highlight" : {
"fields" : {
"comment" : { "pre_tags" : ["<temp>"], "post_tags" : ["</temp>"],
"number_of_fragments" : 0
}
}
}
}
【问题讨论】:
标签: python elasticsearch lucene elasticsearch-dsl pylucene