Working with date ranges in Elasticsearch and Symfony2 Working with date ranges in Elasticsearch and Symfony2 elasticsearch elasticsearch

Working with date ranges in Elasticsearch and Symfony2


I figured this out with the help of this answer: Elasticsearch date range intersection

To get date ranges working properly, you have to combine two filters rather than attempt to do it in one:

$rangeLower = new Filtered(    $mainQuery,    new Range('occurring', array(        'gte' => '2013-11-13'    )));$rangeUpper = new Filtered(    $rangeLower,    new Range('occurring', array(        'lte' => '2014-11-14'    )));$query = new Query($rangeUpper);

This gives the correct results although I'm sure there's a more elegant way of constructing the query.