我有以下格式几个JSON文件: -OR和AND运算
_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?
'.minimumShouldMatch'需要一个字符串仅作为参数,对不对? – BairDev 2015-03-30 13:24:22
@malte你说得对。在这种情况下,它应该是'minimumNumberShouldMatch'和'int',或者'minimumShouldMatch'和'string'。纠正。 – 2015-03-30 13:31:03
我认为这应该是被接受的答案。 +1 – NickGreen 2017-02-07 11:09:45