gpt4 book ai didi

elasticsearch - 在ES查询过滤器上使用match_phrase两次?没有为[match_phrase]注册过滤器

转载 作者:行者123 更新时间:2023-12-03 02:28:28 33 4
gpt4 key购买 nike

我一直在尝试使用多个过滤器来获取文档。

我目前正在使用ES 1.7,是否可以在过滤器上两次使用match_phrase

示例:人员文档q=aaron&address=scarborough-通过姓名和地址搜索人,效果很好。

{
"query": {
"match_phrase": {
"name": "aaron"
}
},
"filter": {
"bool": {
"must": {
"nested": {
"path": "addresses",
"query": {
"match_phrase": {
"address": "scarborough"
}
}
}
}
}
},
q=aaron&phone=813-689-6889-通过姓名和电话号码搜索人也可以正常工作。
{
"query": {
"match_phrase": {
"name": "aaron"
}
},
"filter": {
"bool": {
"must": {
"query": {
"match_phrase": {
"phone": "813-689-6889"
}
}
}
}
}

但是,当我尝试同时使用过滤器,地址和电话时,出现 No filter registered for [match_phrase]错误

例如: q=aaron&address=scarborough&phone=813-689-6889
{
"query": {
"match_phrase": {
"name": "aaron"
}
},
"filter": {
"bool": {
"must": {
"nested": {
"path": "addresses",
"query": {
"match_phrase": {
"address": "scarborough"
}
}
},
"query": {
"match_phrase": {
"phone": "813-689-6889"
}
}
}
}
}

一起使用 addressphone过滤器时出现错误:
nested: QueryParsingException[[pl_people] No filter registered for [match_phrase]]; }]","status":400}):


索引映射(人),具体要求如下:
{
"pl_people": {
"mappings": {
"person": {
"properties": {
"ac_name": {
"type": "string",
"analyzer": "autocomplete"
},
"date_of_birth": {
"type": "date",
"format": "dateOptionalTime"
},
"email": {
"type": "string"
},
"first_name": {
"type": "string",
"fields": {
"na_first_name": {
"type": "string",
"index": "not_analyzed"
}
}
},
"last_name": {
"type": "string",
"fields": {
"na_last_name": {
"type": "string",
"index": "not_analyzed"
}
}
},
"middle_name": {
"type": "string",
"fields": {
"na_middle_name": {
"type": "string",
"index": "not_analyzed"
}
}
},
"name": {
"type": "string",
"fields": {
"na_name": {
"type": "string",
"index": "not_analyzed"
},
"ngram_name": {
"type": "string",
"analyzer": "my_start"
},
"ns_name": {
"type": "string",
"analyzer": "no_stopwords"
}
}
},
"phone": {
"type": "string"
},
"time": {
"type": "date",
"format": "dateOptionalTime"
},
"updated_at": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
}

最佳答案

也许您可以使用term-filter,而不是match_phrase作为过滤器。

参见here

关于elasticsearch - 在ES查询过滤器上使用match_phrase两次?没有为[match_phrase]注册过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60513379/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com