2015-11-04 21 views
0

我有一個elasticsearch查詢,在business_process字段進行過濾。我想添加另一個匹配子句,所以這兩個字段都有指定的數據,我想在business_process字段添加突出顯示。我將如何做到這一點彈性?先謝謝你。如何在此彈性搜索查詢中添加其他條件以進行篩選?

{ 
    "query": { 
    "filtered": { 
     "query": { 
     "match": { 
      "business_process": "loading" 
     } 
     }, 
     "filter": { 
     "missing": { 
      "field": "client_cru_all" 
     } 
     } 
    } 
    } 
} 

回答

1

ES文檔是你的朋友。 bool query可能是你正在尋找的。像這樣的東西應該做你想要的。

POST /test_index/_search 
{ 
    "query": { 
     "filtered": { 
     "query": { 
      "bool": { 
       "must": [ 
        { 
        "match": { 
         "business_process": "loading" 
        } 
        }, 
        { 
        "match": { 
         "another_field": "some text" 
        } 
        } 
       ] 
      } 
     }, 
     "filter": { 
      "missing": { 
       "field": "client_cru_all" 
      } 
     } 
     } 
    } 
} 

只要突出顯示,我會開始here。如果你無法使用它,請發佈你在你的問題中嘗試過的內容。

+0

ES文檔很爛! –

+1

是的,我不反對。不過,即使是一個低劣的朋友也有他的用途。 ;) –

+0

哈哈好點 –