Nested objectes query problem

I am using Java API to query elastic search index. I have indexed data
having complex structure through Couchbase into ElasticSearch. My data is
as follows :

e.g.

{
"detail": {
"lastName": "JOSEPH",
"firstName": "JOHN",
"birthDate": "19621022",
"gender": "M"
},
"vehicles": {
"vehicle": [
{
"state": "CA",
"model": "RAPIDE",
"color1": "BGE",
"color2": "BLK",
"licensePlate": "cdgh34676",
"make": "ASTONMARTIN"
},
{
"state": "LA",
"model": "AUDI",
"color1": "BGE",
"color2": "BLK",
"licensePlate": "abcd1209",
"make": "ASTONMARTIN"
}

    ] 

}
}

My Questions are:

  1. I am querying using:

client.prepareSearch("index_name").setTypes("couchbaseDocument").setQuery(QueryBuilders.fieldQuery("detail.lastName",
"JOSEPH"))).execute().actionGet();

It returns 0 hits but if i set QueryBuilders.fieldQuery("lastName",
"JOSEPH") it returns the result with hit count 1 ?

  1. Can i define Facet on say gender present in detail using .addFacet()
    and adding field as detail.lastName. In my case this is also not working.

  2. How can i define facet on fields color1, color2 present in
    vehicles.vehicle

Thanks,
Bhushan

--

  1. I am querying using:

client.prepareSearch("index_name").setTypes("couchbaseDocument").setQuery(QueryBuilders.fieldQuery("detail.lastName",
"JOSEPH"))).execute().actionGet();

It returns 0 hits but if i set QueryBuilders.fieldQuery("lastName",
"JOSEPH") it returns the result with hit count 1 ?
How do you send the above json example as document to ES?

  1. Can i define Facet on say gender present in detail using .addFacet()
    and adding field as detail.lastName. In my case this is also not working.
    Can you share the how you're currently doing this? What you're
    describing should work.
  1. How can i define facet on fields color1, color2 present in
    vehicles.vehicle
    Are color1 and color2 the same logical property in your domain? If so
    why not index these colors in one field? The terms facet does support
    creating facet counts from multiple fields:
    Elasticsearch Platform — Find real-time answers at scale | Elastic

Martijn

--