2
我希望能夠排除ElasticSearch查詢中的多個節點。目前這段代碼運行良好,但它只會排除兩個節點($ nodeId1和$ nodeId2)。使用數組的ElasticSearch bool搜索
我將如何更改此查詢,以便我可以使用包含儘可能多的節點ID的數組?謝謝。
$data_string = '{
"from" : 0, "size" : "' . $maximumResults . '",
"query": {
"filtered": {
"query": {
"match" : {
"thread.title" : {
"query" : "' . $threadTitle . '",
"operator": "or"
}
}
},
"filter": {
"bool" : {
"must" : [],
"must_not" : [
{
"term" : {"thread.discussion_id" : "' . $currentThreadId . '"}
},
{
"term" : {"thread.node" : "' . $nodeId1 . '"}
},
{
"term" : {"thread.node" : "' . $nodeId2 . '"}
}
],
"should" : []
}
}
}
}
}';
謝謝你,丹。這正是我需要的信息,你的榜樣工作得很好。我最終創建了一個簡單的$ where語句,現在我可以根據需要輕鬆添加儘可能多的nodeIds。 – 2014-10-27 15:45:45