2015-12-15 35 views
0

我想要搜索某個特定鍵的值是否存在於節點中。使用沒有「id」鍵的彈性搜索發起查詢

{ 
    "_index": "some_index", 
    "_type": "some_type", 
    "_id": "some_id", 
    "_version": ver, 
    "found": true, 
    "_source": { 
    "timestamp": "timestamp", 
    "fragments": ["1234", "5678", "8912"] 
    } 
} 

在這種情況下,這將是在Java中查詢,如果我想找到5678是否片段存在,與輸出繼電器爲:5678 exist

+2

而你的問題? –

+0

運行卷曲命令工作,即: curl -XGET「http:// localhost:port/index/type/_search/exists?q

回答

0
fragment = "xyz" 
SearchResponse response = client.prepareSearch(_index) 
      .setTypes(_type) 
      .setQuery(QueryBuilders.matchQuery("fragments", fragment)) 
      .execute().actionGet(); 

工作在我的情況。