I am trying to implement has_child with ES java client. The mapping looks like that:
curl -XPUT 'http://localhost:9200/users/' -d '
{
"mappings": {
"user": {
"properties": {
"firstName": {
"type": "string",
"analyzer": "standard"
}
}
},
"meta": {
"_parent": {
"type": "user"
},
"properties": {
"data": {
"type": "string",
"analyzer": "standard"
},
"business": {
"type": "string",
"index" : "not_analyzed"
}
}
}
}
}
'
I can successfully search via REST API with:
curl "http://localhost:9200/users/user/_search" -d '{
"query": {
"bool": {
"must": [
{
"query_string" : {
"fields": ["firstName"],
"query": "Cho"
}
},
{
"has_child": {
"type": "meta",
"query": {
"simple_query_string" : {
"query": "int*",
"fields": [ "data" ]
}
}
}
}
]
}
}
}'
but can't make it work with java client. The code I have:
SearchRequestBuilder requestBuilder = client.prepareSearch("users")
.setTypes("user", "meta")
.setQuery(
boolQuery()
.must(queryStringQuery(String.format("%s*", queryString)).field("firstName"))
.must(hasChildQuery("meta", simpleQueryStringQuery(String.format("%s*", queryString)).field("data")))
.setFrom(page)
.setSize(size);
SearchResponse searchResponse = requestBuilder
.execute()
.actionGet();
Both versions (server and client) are 2.1.0. I repeat - the parent/child relations are fine since I can search via REST API. Any thoughts?