FosElasticaBundle:一个索引中包含多种类型

San*_*cho 5 php symfony foselasticabundle

我需要建立一个多实体搜索。

我不想每个T1,然后每个T2。

使用时fos:lastica:populate,出现错误:

拒绝将映射更新更新为[search_dev],因为最终映射将具有1种以上的类型:[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
Run Code Online (Sandbox Code Playgroud)

我的服务:

$search = $this->indexManager->getIndex('search')->createSearch();
$search->addType('t1');
$search->addType('t2');
$resultSet = $search->search($query);

$results = $this->modelTransformer->transform($resultSet->getResults());
Run Code Online (Sandbox Code Playgroud)

我错过了什么?我可以在1个索引中映射2种类型吗?

Yoh*_* G. 3

这与 Elastica 无关,而是与 Elasticsearch 6.0 相关:https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html

我有同样的问题,目前没有找到一种简单的方法来将多个学说模型映射到单个索引中。