I have a Query to matchAll product in ElasticSearch. It run perfeclty but I want to add a Sort for this Query. I don't find example which run and I don't understand why it generate error.
This code for sorting query :
$match = new \Elastica\Query\MatchAll();
$query = new \Elastica\Query($match);
$query->addSort([
'product.price' => ['order' => 'asc']
]);
return $this->find($query);
Generate this error :
Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])
I try lot of thing before post this but the error is always the same.
ElasticSearch : 5.2.2
FosElasticaBundle : 3.2.2
PHP : 5.6.30
Symfony : 2.8
This error means that is a incompatibility between ES, Elastica and FosElasticBundle. Warning ES and base PHP labrary Elastica...
this code run perfectly :
$query = new Query();
$queryRange = new \Elastica\Query\Range('product.price', array('gt' => 0, 'lt' => 20));
$query->setQuery($queryRange);
return $this->find($query);
ElasticSearch : 1.7.4
FosElasticaBundle : 3.2.2
PHP : 5.6.30
Symfony : 2.8