我需要构建一个多实体搜索。
我不想要每个 T1,然后每个 T2。
当我使用 fos:lastica:populate
时,出现错误:
Rejecting mapping update to [search_dev] as the final mapping would have more than 1 type: [t1, t2]
我的映射:
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/