How to use api get mutil parent/child inner_hits

i'm using the version 6.3.2.
use the client


how to use api get mutil parent/child inner_hits?

//code the api below is get dept and their users

public void queryDetails() {
	QueryBuilder qb = JoinQueryBuilders.hasChildQuery("user", // child relation
			QueryBuilders.matchQuery("uname.keyword", "lucy"), ScoreMode.None).innerHit(new InnerHitBuilder());
	SearchQuery searchQuery = new NativeSearchQueryBuilder().withIndices("user_test").withQuery(qb).build();
	List<DeptVO> depts = elasticsearchTemplate.query(searchQuery, searchResponse -> {
		SearchHits hits = searchResponse.getHits();
		List<DeptVO> list = new ArrayList<>(); -> {
			Map<String, Object> source = h.getSourceAsMap();
			SearchHits innerHitsMap = h.getInnerHits().get("user");// get child

			List<User> user1s = -> {
				Map<String, Object> innerSource = innerH.getSourceAsMap();
				return new User(innerSource.get("uname").toString(),
			list.add(new DeptVO(source.get("dname").toString(), user1s));
		return list;

if i have child in "user", like address, how to get it?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.