gpt4 book ai didi

elasticsearch - Kibana多个关键字过滤器

转载 作者:行者123 更新时间:2023-12-02 23:57:21 31 4
gpt4 key购买 nike

我需要数据的多次过滤方面的帮助。例如,对于下面的示例JSON,哪种查询最有效?如果我只需要搜索所有字段,例如“Apple”和水果“Y”

1)

{
"_index": "abc",
"_type": "123",
{
"field" : "Apple"
"fruit" : "Y"
},
{
"field" : "Tomato"
"fruit" : "N"
},
{
"field" : "Mango"
"fruit" : "Y"
}

2)
{
"_index": "abc",
"_type": "123",
{
"field" : "Apple"
"fruit" : "N"
},
{
"field" : "Tomato"
"fruit" : "Y"
},
{
"field" : "Mango"
"fruit" : "Y"
}

最佳答案

可能您想研究ES search docsES Filters
希望这可以帮助您了解进行搜索的想法:

{
"bool": {
"must": { "match": { "tweet": "elasticsearch" }},
"must_not": { "match": { "name": "mary" }},
"should": { "match": { "tweet": "full text" }},
"filter": { "range": { "age" : { "gt" : 30 }} }
}
}

对于完全匹配,您可以将 use 'term' from ES docs设置为:
{
"bool": {
"must": [ { "term": { "field": "Apple" }},
{ "term": { "fruit": "Y" }} ]
}
}

在Kibana中使用:
GET index_name/_search
{
"query": {
# your search query here
}
}

可能这不是最佳解决方案,但希望对您有所帮助。

更新

ES demo上尝试

TEST

要运行的示例代码:
GET kibana_sample_data_flights/_search
{
"query": {
"bool": {
"must": [
{"match": {
"OriginWeather": "Sunny"
}},
{"match": {
"Cancelled": false
}}
]
}
}
}

关于elasticsearch - Kibana多个关键字过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52323648/

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