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

www.yakaz.com

2011/7/20 tsolakp [via Elasticsearch Users] <
ml-node+3186014-13754093-393975@n3.nabble.com>

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")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery( boolQuery().must( fieldQuery("property.sales.price", *

135000* ) ).must( fieldQuery("property.sales.saleDate", date.getTime() ) )
)
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();

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
below:

http://elasticsearch-users.115913.n3.nabble.com/Nested-object-query-tp3186014p3186014.html
To start a new topic under Elasticsearch Users, email
ml-node+115913-1699315842-393975@n3.nabble.com
To unsubscribe from Elasticsearch Users, click herehttp://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=115913&code=b2xpdmllckB5YWthei5jb218MTE1OTEzfDIxMjI2MTYwOTc=.