Search using nested type does not return results

I have to index documents having multi-level nesting. I am able to create
mapping and index successfully. But when I search using nested query
wrapping multi-match query I dont get any results. Looks like indexed
fields used for searching are not enough. How to determine the name of the
fields (for all nested levels) when multilevel nesting is used

My mapping looks like

XContentBuilder xbMapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("nested_mapping")
.startObject("properties")
.startObject("id").field("type", "string").field("index",
"analyzed").endObject()
.startObject("name").field("type", "string").field("index",
"analyzed").endObject()
.startObject("subprocess").field("type", "nested").field("index",
"analyzed").endObject()
.endObject()
.endObject()
.endObject();

My indexed documents are :

String jsonString = "{"id":"level2","desp":"simple
desc","subProcess":{"name":"L3"}}";
writeNestedIndex(jsonString,"nested_mapping","str1");

jsonString
="{"id":"level1","subProcess":{"id":"level2","subProcess":{"name":"L3"}}}";
writeNestedIndex(jsonString,"nested_mapping","str2");

jsonString =
"{"id":"level0","name":"L0","subProcess":{"id":"level1","name":"L1","subProcess":{"id":"level2","name":"L2","subProcess":{"id":"level3","name":"L3","desp":"extended"}}}}";
writeNestedIndex(jsonString,"nested_mapping","str3");

public static void writeNestedIndex(String jsonStr, String mapping, String
id) throws Exception {
IndexRequestBuilder builder = client.prepareIndex();
builder.setIndex("nested_sample");
builder.setType(mapping);
builder.setId(id);
builder.setSource(jsonStr);
try {
client.index(builder.request()).get();
}
catch (Exception e) {
e.printStackTrace();
}
}

Code snippet of search looks like

SearchRequestBuilder srb = client.prepareSearch("nested_sample");
BoolQueryBuilder boolQueryBuilder= QueryBuilders.boolQuery();
srb.setTypes("nested_mapping","default");
MultiMatchQueryBuilder qb = QueryBuilders.multiMatchQuery("L3");
//Add fields to be searched
String[] fields = {"subprocess.id",
"name","subprocess.name","subprocess.desp","desp"};
for(int i=0;i<fields.length;i++) {
qb.field(fields[i]);
}
boolQueryBuilder.should(qb);
NestedQueryBuilder nestedBuilder = QueryBuilders.nestedQuery("subprocess",
qb);
nestedBuilder.scoreMode("avg");
srb.setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setQuery(nestedBuilder);
SearchResponse response = client.search(srb.request()).get();
SearchHit[] hits = response.hits().getHits();
System.out.println("Hit size : " + hits.length);
for (int i = 0; i < hits.length; i++) {
String source = hits[i].getSourceAsString();
System.out.println(source);
}

Though the query "L3" present in index repository I dont get any results.
Am I missing anything, please help

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.