gpt4 book ai didi

elasticsearch - Elasticsearch应该操作查询

转载 作者:行者123 更新时间:2023-12-03 00:55:59 26 4
gpt4 key购买 nike

我该如何暗示“应该”操作
(“tag” =“A” OR“tag” =“B”)和“name” =“cat”

喜欢 ?

 BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("tag","A"))
.shold(QueryBuilders.matchQuery("tag","B"))

.must(QueryBuilders.matchQuery(“name”,“cat”)));

最佳答案

如果要执行("tag"="A" OR "tag"="B") and "name"="cat",则可以执行以下操作:

 BoolQueryBuilder aOrB = QueryBuilders.boolQuery()
.should(QueryBuilders.matchQuery("tag","A"))
.should(QueryBuilders.matchQuery("tag","B"))

BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery()
.must(aOrB);
.must(QueryBuilders.matchQuery("name","cat"));

关于elasticsearch - Elasticsearch应该操作查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44023864/

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