我需要建立一个多实体搜索。
我不想每个T1,然后每个T2。
当我使用fos:lastica:populate
时,出现错误:
我的映射:
fos_elastica:
clients:
default:
host: %elastic_host%
port: %elastic_port%
indexes:
search:
finder: ~
client: default
index_name: search_%kernel.environment%
types:
t1:
indexable_callback: 'getEnabled'
properties:
id:
type: integer
name: ~
persistence:
driver: orm
model: AppBundle\Entity\T1
finder: ~
listener:
logger: true
elastica_to_model_transformer:
ignore_missing: true
t2:
indexable_callback: 'getEnabled'
properties:
id:
type: integer
name: ~
persistence:
driver: orm
model: AppBundle\Entity\T2
finder: ~
listener:
logger: true
elastica_to_model_transformer:
ignore_missing: true
我的服务:
$search = $this->indexManager->getIndex('search')->createSearch();
$search->addType('t1');
$search->addType('t2');
$resultSet = $search->search($query);
$results = $this->modelTransformer->transform($resultSet->getResults());
我错过了什么?我可以在1个索引中映射2种类型吗?
最佳答案
我一直在寻找一种获取产品和类别并得到相同错误的方法。当我四处移动并建立多个索引时,它起作用了:
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
products:
types:
product:
properties:
...
persistence:
...
categories:
types:
category:
properties:
...
persistence:
...
关于php - FosElasticaBundle:一个索引中包含多种类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47379155/