I am trying to integrate search by date range with PHP and elastic search
$params1 = [
'index' => 'joborders',
'type' => 'joborder',
'from' =>0,
'size' => 50,
'body' => [
'query' => [
'query_string' => [
'query' => $wildCardString,
'fields' => ['description'],
]
]
]
];
$filter_date=array();
$filter_date['range']['datecreatedsort']['gte']='2015-11-27';
$filter_date['range']['datecreatedsort']['lte']='2017-11-27';
$params1['body']['query']['filtered']['filter']=$filter_date;
$params1['body']['sort']['datecreatedsort']['order'] = 'desc';
try {
$results = $client->search($params1);
//print_r($results);
}
catch (Exception $e) {
$last = $client->transport->getLastConnection()->getLastRequestInfo();
$last['results']['error'] = [];
print_r($last);
}
When I am running above query I am getting following error
[query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":78},"status":400}
datecreatedsort filed mapping is date type is date and value in elastic search db is "datecreatedsort":"2016-05-30T09:39:40.000Z"
please help where is the issue in elastic query.