0
我在Elasticsearch中有父子關係的文檔。我在java客戶端中執行搜索操作並獲取子文檔。有getId()
,getIndex()
,getType()
,getSource()
使用方法,但不使用getParent()
。如何在java中獲取父ID?如何在java中獲取Elasticsearch中的文檔的父ID?
我在Elasticsearch中有父子關係的文檔。我在java客戶端中執行搜索操作並獲取子文檔。有getId()
,getIndex()
,getType()
,getSource()
使用方法,但不使用getParent()
。如何在java中獲取父ID?如何在java中獲取Elasticsearch中的文檔的父ID?
在迭代響應匹配時,可以使用SearchHit.field("_parent")
方法來檢索父文檔的ID。
SearchResponse response = client.prepareSearch().execute().actionGet();
for (SearchHit hit : response.getHits().getHits()) {
SearchHitField parent = hit.field("_parent");
}
It works.Thanks!謝謝! –
很高興幫助! – Val
我還有一個問題。 http://stackoverflow.com/questions/38738573/how-to-know-if-a-type-of-a-index-has-parent-or-child-relationship-in-elasticsear –