在 ElasticSearch 中使用模糊和前缀匹配 Span_multi
Using Fuzzy and Prefix match with Span_multi in ElasticSearch
我的用例是在基于模糊和前缀匹配检索的字段中突出显示多个 phrases/words。为此,我目前使用 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
}
}
}
}
嘿,它正在与
合作
"comment": {
"fuzziness": "5",
"value": "Rosenane",
"prefix_match":3
}
我的用例是在基于模糊和前缀匹配检索的字段中突出显示多个 phrases/words。为此,我目前使用 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
}
}
}
}
嘿,它正在与
合作"comment": {
"fuzziness": "5",
"value": "Rosenane",
"prefix_match":3
}