Create FOSElasticaBundle action in controller

时间:2015-05-24 20:57:03

标签: symfony foselasticabundle

I decided to deal with ElasticSearch. Immediately faced with the problem of writing action in the controller. Here is my configuration. Can someone write a small example of how to use this bundle for these fields

fos_elastica:
clients:
    default: { host: localhost, port: 9200 }

1 个答案:

答案 0 :(得分:0)

您可以使用该命令填充索引php app/console fos:elastica:populate

然后查找您可以在控制器操作中使用的用户:

$finder = $this->container->get('fos_elastica.finder.search.user');

// Option 1. Returns all users who have example.net in any of their mapped fields
$results = $finder->find('example.net');
像在文档中一样,它通常是自我解释的:

https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/usage.md

如果您的代码中存在问题,如果您想要一个已经存在的示例,我们可能会有帮助,我只是复制粘贴它,因为没有太多要添加。