gpt4 book ai didi

elasticsearch - 如何使用模糊和通配符查询来查询Elasticsearch嵌套对象

转载 作者:行者123 更新时间:2023-12-02 23:16:46 26 4
gpt4 key购买 nike

{  
"took":1,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":1,
"max_score":1,
"hits":[
{
"_index":"event_11",
"_type":"_doc",
"_id":"1",
"_score":1,
"_source":{
"title":"Event One",
"comments":{
"author":"Alvin",
"author_id":1
}
},
"inner_hits":{
"comments":{
"hits":{
"total":1,
"max_score":1,
"hits":[
{
"_index":"event_11",
"_type":"_doc",
"_id":"1",
"_nested":{
"field":"comments",
"offset":0
},
"_score":1,
"_source":{
"author":"Alvin",
"author_id":1
}
}
]
}
}
}
}
]
}
}

我正在尝试使用以下通配符查询来查询上述数据:
GET event_11/_search
{
"query": {
"nested": {
"path": "comments",
"query": {
"wildcard": {
"comments.author": "Al*"
}
}
}
}
}

上面的查询给出了空的结果集。有人可以帮助我使用通配符和模糊性来修复搜索查询吗?我正在使用ElasticSearch 6和Kibana创建查询。 PHP SDK用于从PHP应用程序编写查询。

最佳答案

你可以试试看

  {
"query": {
"nested": {
"path": "comments",
"query": {
"bool": {
"should": [
{
"wildcard": {
"comments.author": "real*"
}
},
{
"match": {
"comments.author": {
"query": "reaa",
"fuzziness": "AUTO"
}
}
}
]
}
}
}
}
}

关于elasticsearch - 如何使用模糊和通配符查询来查询Elasticsearch嵌套对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53665419/

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