I am using FOSElasticaBundle in my project to search on my object Player. Since I only want to search for objects with a property isactiveby value 1, I followed the documentation on the "Filter Results and Perform Query by Default" page : FriendsOfSymfony / FOSElasticaBundle / README.md
$query = new \Elastica\Query\QueryString($searchterm);
$term = new \Elastica\Filter\Term(array('isactive' => true));
$filteredQuery = new \Elastica\Query\Filtered($query, $term);
$players = $this->get('fos_elastica.finder.xxx.player')->find($filteredQuery);
My package configuration is as follows:
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
serializer:
callback_class: FOS\ElasticaBundle\Serializer\Callback
serializer: serializer
indexes:
xxx:
client: default
types:
player:
mappings:
firstname: { boost: 3 }
lastname: { boost: 3 }
serializer:
groups: [elastica, Default]
persistence:
driver: orm
model: xxx\FrontendBundle\Entity\Player
listener: ~
provider: ~
finder: ~
Now I want to do some sorting and shorten the result with constraint and offset. How can I achieve this?
I found a solution like
$finalQuery = new \Elastica\Query($boolQuery);
$finalQuery->setSort(array('price' => array('order' => 'asc')));
But I do not have an Elastica \ Query object, and AbstractQuery does not support this method. Same thing with
$elasticaQuery->addSort($sort);
What to do? Where to read ???: //
(besides, if we are already here: what does {boost: 3} really do?)