我有以下格式幾個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