gpt4 book ai didi

elasticsearch - Elasticsearch 2.x至5.x查询问题

转载 作者:行者123 更新时间:2023-12-03 01:39:34 25 4
gpt4 key购买 nike

下面的查询需要从2.x版本更改为5.x版本。
filtered => bool
但是应该不支持多个查询。

"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [{
"query": {
"match": {
"valid": "Y"
}
}
}],
"should": [
{ "query": { "wildcard": { "name": { "value": '*' + searchValue + '*' } } } },
{ "query": { "wildcard": { "fisrtname": { "value": '*' + searchValue + '*' } } } }
]
}
}
}
},
"sort": [{
"name": {
"order": "asec"
}
}],
"from": 0,
"size": 15

最佳答案

像这样:

{
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"match": {
"valid": "Y"
}
}
],
"should": [
{
"wildcard": {
"name": {
"value": "searchValue"
}
}
},
{
"wildcard": {
"firstname": {
"value": "searchValue"
}
}
}
]
}
}
}
},
"sort": [
{
"name": {
"order": "asc"
}
}
],
"from": 0,
"size": 15
}

第一个bool.filter包装器是这样,因此所有内容都被视为过滤器,不会被评分并且可能会被缓存。

关于elasticsearch - Elasticsearch 2.x至5.x查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49009723/

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