2016-08-03 78 views

回答

1

在迭代响应匹配时,可以使用SearchHit.field("_parent")方法来检索父文档的ID。

SearchResponse response = client.prepareSearch().execute().actionGet(); 
for (SearchHit hit : response.getHits().getHits()) { 
    SearchHitField parent = hit.field("_parent"); 
} 
+0

It works.Thanks!谢谢! –

+0

很高兴帮助! – Val

+0

我还有一个问题。 http://stackoverflow.com/questions/38738573/how-to-know-if-a-type-of-a-index-has-parent-or-child-relationship-in-elasticsear –