Also i am testing this way too
final BoolQueryBuilder builder = boolQuery();
builder.must(nestedQuery("userdetails.users", termQuery("users.userName", "farooqesee")));
System.out.println("builder:"+builder);
final SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(builder)
.build();
Page<UserDetail> pageObj = userDetailElasticSearchRepository.search(searchQuery);
System.out.println("Size Users:"+pageObj.getContent().size());
my query built...
builder:{
"bool" : {
"must" : {
"nested" : {
"query" : {
"term" : {
"users.userName" : "farooqesee"
}
},
"path" : "userdetails.users"
}
}
}
}
But IDE Exception......
searchUser(com.binaryvibes.wms.springapp.UserServiceTest) Time elapsed: 0.195 sec <<< ERROR!
org.elasticsearch.action.search.SearchPhaseExecutionException:
Failed to execute phase [dfs], all shards failed; shardFailures {[Y-0-CO9uQEqHvBWuhfvT8A][userdetails][0]: SearchParseException[[userdetails][0]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"bool":{"must":{"nested":{"query":{"term":{"users.userName":"farooqesee"}},"path":"userdetails.users"}}}}}]]]; nested:
QueryParsingException[[userdetails] [nested] failed to find nested object under path [userdetails.users]]; }{[Y-0-CO9uQEqHvBWuhfvT8A][userdetails][1]:
SearchParseException[[userdetails][1]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"bool":{"must":{"nested":{"query":{"term":{"users.userName":"farooqesee"}},"path":"userdetails.users"}}}}}]]]; nested: QueryParsingException[[userdetails] [nested] failed to find nested object under path [userdetails.users]]; }{[Y-0-CO9uQEqHvBWuhfvT8A][userdetails][2]:
SearchParseException[[userdetails][2]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"bool":{"must":{"nested":{"query":{"term":{"users.userName":"farooqesee"}},"path":"userdetails.users"}}}}}]]]; nested: QueryParsingException[[userdetails] [nested] failed to find nested object under path [userdetails.users]]; }{[Y-0-CO9uQEqHvBWuhfvT8A][userdetails][3]:
SearchParseException[[userdetails][3]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"bool":{"must":{"nested":{"query":{"term":{"users.userName":"farooqesee"}},"path":"userdetails.users"}}}}}]]]; nested: QueryParsingException[[userdetails] [nested] failed to find nested object under path [userdetails.users]]; }{[Y-0-CO9uQEqHvBWuhfvT8A][userdetails][4]:
SearchParseException[[userdetails][4]: from[0],size[10]: Parse Failure [Failed to parse source [{"from":0,"size":10,"query":{"bool":{"must":{"nested":{"query":{"term":{"users.userName":"farooqesee"}},"path":"userdetails.users"}}}}}]]]; nested: QueryParsingException[[userdetails] [nested] failed to find nested object under path [userdetails.users]]; }
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:237)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:183)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:565)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
ElasticSearch Console Exception...
Caused by: org.elasticsearch.index.query.QueryParsingException: [userdetails] [nested] failed to find nested object under path [userdetails.users]