Elasticsearch Range Filter

Hi,
I am using PHP 5.1, Mysql and Elasticsearch 2.1.
I indexed my datas to Elasticsearch from Mysql .
I am doing filter and query now. I have date field.
I want to do date range filter and query.

My codes:

unset($filter_date);
if(isset($_GET['date_gte'])){
$filter_date['range']['date']['gte']=$_GET['date_gte'];
$filter_date['range']['date']['lte']=$_GET['date_lte'];
}
if(is_array($filter_date)){
$searchParams['body']['query']=$filter_datei;
}

My query on URL:
10.0.2.15:8080/filters.php?date_gte=2013-31-01 00:00:00&date_lte=2015-31-01

Unfortunately it dosen't return results. Please help me

Does it work with date_gte=2013-01-01&date_lte=2015-01-01?

Make sure your date format is the same as defined in the mapping.

Date mapping code:

$myTypeMapping['properties']['date']['type']='date';
$myTypeMapping['properties']['date']['index']='not_analyzed';

Not the same format as the query you sent. Read the doc about date mapping and its default format.

I read.

$myTypeMapping['properties']['date']['type']='date';
$myTypeMapping['properties']['date']['index']='analyzed';
$myTypeMapping['properties']['date']['format']='yyyy-MM-dd';

Is it true?

Try with:

1 Like

ok It is done Thank you