gpt4 book ai didi

elasticsearch - 如何在Elasticsearch中按数组字段搜索?

转载 作者:行者123 更新时间:2023-12-03 01:50:37 30 4
gpt4 key购买 nike

我已经索引了这样的文档:

[PUT] /my_index/cars/1

{
"color" : "red",
"passengers" : ["John", "Annie", "William"]
}

我正在尝试搜索“约翰”是乘客的所有汽车。

最佳答案

您可以像搜索其他任何字段一样进行搜索。

-bash-4.2$ curl 'localhost:9200/my_index/_search?pretty=true&q=passengers:John'
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.15342641,
"hits" : [ {
"_index" : "my_index",
"_type" : "cars",
"_id" : "1",
"_score" : 0.15342641,
"_source" : {
"color" : "red",
"passengers" : [ "John", "Annie", "William" ]
}
} ]
}
}

关于elasticsearch - 如何在Elasticsearch中按数组字段搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40753269/

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