Nested object query

  • deleted -

Like your title says: use "nested" queries:

Don't forget to define you're mapping accordingly:

(The link on the first page to the second is broken in the docs)

Olivier Favre

2011/7/20 tsolakp [via Elasticsearch Users] <>

I have a query like this:

Date date = DateUtils.parseDate( "2004-11-23T07:00:00.000-0000", new
String{"yyyy-MM-dd'T'hh:mm:ss.sssZ"} );

SearchResponse response = client.prepareSearch("props")
.setQuery( boolQuery().must( fieldQuery("property.sales.price", *

135000* ) ).must( fieldQuery("property.sales.saleDate", date.getTime() ) )

which returns the following single document:

{property={suitableForModeling=Y, location={lon=-104.930714,
lat=39.700083}, bathrooms=1, propStyle:r=R, bedrooms=2, price=135000,
lastSalePrice=135000,* sales=[{price=135000,
saleDate=2009-09-08T06:00:00.000Z}, {price=142900,
saleDate=2004-11-23T07:00:00.000Z}]*, propType=CND, yoc=1982,
saleDate=2009-09-08T06:00:00.000Z, acres=0.01, mainSqft=745}}

How can I tell ES to apply query to one "property.sales" at a time. What I
want is not get any hits with the above query since first sale does not have
saleDate of "2004-11-23T07:00:00.000-0000".

If you reply to this email, your message will be added to the discussion
To start a new topic under Elasticsearch Users, email
To unsubscribe from Elasticsearch Users, click here