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 –