2017-07-31 67 views
1

2關於搜索_id領域的問題:elastic4s搜索ID

  1. ,我想找到是否存在特定ID使用elastic4s DSL。在aquivilent這個查詢elasticsearch API:

    捲曲-XGET 'http://localhost:9200/indexName/indexType/_search/exists?q=_id:foo'

我試圖做這樣的事情:

client execute search(indexName/indexType) query ("_id", "foo") 

,但是這會產生SearchDefinition不能被isExists檢查

  1. 我想取所有_id的 到目前爲止,我得到了這個解決辦法,但我不知道這是idomatic辦法做到這一點

    client.execute(搜索(INDEXNAME/INDEXTYPE)查詢‘ID’)。圖( .ids )

回答

1

您可以查詢ID,ID分別查詢https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html#query-dsl-ids-query

search("electronics"/"phone").query(idsQuery("foo")) 
+0

謝謝,但泰國人將獲取整個文件。我只是想檢查它是否存在 – igx

+0

我可以做類似'search(「electronics」/「phone」)。query(idsQuery(「foo」))。map(_。nonEmpty)' – igx

+0

你會接受我的回答? – MartinSchulze