floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 73 forks source link

Get specific fields #180

Closed dev-yann closed 6 years ago

dev-yann commented 6 years ago

Can i have a query example for get a specific fields ? I try this but it doesn't work

$query = $client->createQuery('Wim\Api\Document\Objet');
$query->addField('id');
 $query->createFilterQuery('bounds')->setQuery('location.geo:[' . $bounds1 . ',' . $bounds2 . ' TO ' . $bounds3 . ',' . $bounds4 . ']');
$query->getResult();

This code should give me only 'id' list, no ? ( I have all fields in result )

floriansemm commented 6 years ago

$query->getResult() will return a array of mapped objects and not a list of fields

dev-yann commented 6 years ago

Okai but do you know how can i get two or more specific fields ? If I want Id, name and surname for example ?

floriansemm commented 6 years ago

you can use Solarium API for that. Call the solr.client.adapter service to get the solarium-client.