0
$finder = $this->container->get('fos_elastica.finder.index.type');

$result = $finder->find('string_to_find');

My entity consists of 20 properties and elastic has only 3 fields. in $result I will have all 20 properties. How I can have only these 3 properties which I do search on.
Generally I would like to know how I can handle properties which will be in result variable?

here is config.yml

persistence:model: MyBundle\Entity\EntityName

Brendan
  • 908
  • 2
  • 15
  • 30

1 Answers1

0

When you use find you have transformed results (Your entities), if you use findHybrid the bundle returns the elastic results and de transformed results;

$results = $finder->findHybrid('example.net');

I hope this can help you

Jose M. González
  • 12,590
  • 1
  • 13
  • 9
  • Thank you for quick response. however it still returns "transformed" section which has all fields from my entity. The issue I'm trying to fix is response time. As far as I can understand - symfony does additional call to mysql to get all fields from what have been found by elastic. Can I just skip it? because I only need these very few (3) fields from elastic. thanks! – Oleh Ismailov May 25 '16 at 14:46
  • I found this post http://stackoverflow.com/questions/24070164/foselasticabundle-and-doctrine-hydration?rq=1 which is very helpful. One more thing - fos_elastica.index.search.{type_name} doesn't have method 'find'. What method(s) should I use to get/see result? – Oleh Ismailov May 25 '16 at 15:13
  • In the documentation put the code $this->container->get('fos_elastica.finder.app.{type_name}') to catch the service, for me this service works, i don't found the service like you describe in the bundle documentation [Basic search](https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/usage.md#basic-searching-with-a-finder) – Jose M. González May 25 '16 at 17:27
  • By the way, If you could use PhpStorm with the Symfony plugin, it reveals all the methods from a service and autocomplete it – Jose M. González May 25 '16 at 20:53