我有一个问题,我无法解决,为此我尝试了在网上找到的所有内容。
因此,我在Symphony中还是一个新手,到目前为止,在我需要实现搜索引擎之前,我还没有遇到任何问题。我查看并发现Elastico是一个很好的选择,因此我决定实现它。
我已经使用composer安装了它,没有问题。对于最基本的搜索,我的配置如下所示:
fos_elastica:
clients:
default: { host: localhost, port: 80 }
indexes:
search:
client: default
types:
story:
mappings:
name: ~
persistence:
driver: orm
model: Website\WebBundle\Entity\Story
provider: ~
listener: ~
finder: ~
我使用
php app/console fos:elastica:populate
生成数据没有任何问题。结果将被严格插入(将一个或多个条目与数据库条目匹配)。因此,我的问题是无法显示任何结果。我总是有空数组作为结果:
$finder = $this->container->get('fos_elastica.finder.search.story');
$results = $finder->find('name');
的结果也为空:
$repositoryManager = $this->container->get('fos_elastica.manager');
$repository = $repositoryManager->getRepository('WebsiteWebBundle:Story');
$results = $repository->find('name');
而且我在数据库中有一个名为“名称”的记录,因此我应该得到结果。搜索字母也不起作用。
那么,有人可以告诉我我做错了什么吗?还是有什么方法可以显示所有结果,以便我可以看到结果在那里并且只有搜索失败?
谢谢
最佳答案
您错过了映射配置。
您必须指定要编入索引的Class故事的属性
即:
mappings:
id:
type: integer
关于php - 在Symfony2中使用FOSElasticaBundle进行的任何搜索都为空数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24497006/