我在我的电脑上安装了弹性搜索,我将fos_elastica软件包添加到我的symfony3项目中并进行了配置。 填充我的数据后
bin/console fos:elastica:populate
执行搜索请求时,它总是返回0结果(空数组):[]
这是我的fos_elastica.yml文件
> fos_elastica:
> clients:
> default: { host: %elastic_host%, port: %elastic_port% }
> indexes:
> app:
> client: default
> types:
> user:
> mappings:
> username: ~
> email: ~
> persistence:
> # the driver can be orm, mongodb, phpcr or propel
> # listener and finder are not supported by
> # propel and should be removed
> driver: orm
> model: Appbundle\Entity\User
> provider: ~
> listener: ~
> finder: ~
> post:
> mappings:
> id:
> type: integer
> title : ~
> body : ~
> persistence:
> driver: orm
> model: Appbundle\Entity\Post
> finder: ~
> provider: ~
> listener: ~
这是我在我的控制器中的功能:
/**
* @Route("/post/searchfind",name="postsearchfind")
*/
public function findAction()
{
$finder = $this->container->get('fos_elastica.finder.app.post');
// Option 1. Returns all users who have mm in any of their mapped fields
$results = $finder->find('a');
var_dump($results);
return new JsonResponse($results);
}
请帮忙,对不起英语!