弹性搜索查询中的 OR 和 AND 运算符
2022-09-02 02:44:31
我有几个json文档,格式如下:-
_source: {
userId: "A1A1",
customerId: "C1",
component: "comp_1",
timestamp: 1408986553,
}
我想根据以下内容查询文档:-
(( userId == currentUserId) OR ( customerId== currentCustomerId) OR (currentRole ==ADMIN) ) AND component= currentComponent)
我尝试使用SearchSourceBuilder和QueryBuilders.matchQuery,但我无法使用AND和OR运算符放置多个子查询。
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("userId",userId)).sort("timestamp", SortOrder.DESC).size(count);
如何使用 OR 和 AND 运算符查询 elasticsearch?