FosElasticaBundle:一个索引中有多个类型

时间:2017-11-19 16:31:01

标签: php symfony foselasticabundle

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

我不想要每一个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_dev],因为最终的映射有多种类型:[t1,t2]

我的映射:

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

$results = $this->modelTransformer->transform($resultSet->getResults());

我的服务:

Insert into booking values 
('EWKF2VN','Canada',TO_DATE(11/20/12,'DD/MON/YY'),
TO_DATE(1/10/18 4:00PM,'DD/MON/YY HH:MIAM'),
TO_DATE(1/10/18 6:30PM,'DD/MON/YY HH:MIAM'),
'B',125.00,Booked,'AC101',8521169618);

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

2 个答案:

答案 0 :(得分:3)

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

我有同样的问题,暂时找不到在单个索引中映射多个学说模型的简单方法。

答案 1 :(得分:3)

我一直在寻找获得产品和类别的方法并得到同样的错误。当我移动它并制作多个索引时它起作用了:

fos_elastica:
  clients:
    default: { host: localhost, port: 9200 }
  indexes:
    products:
      types:
        product:
          properties:
            ...
          persistence:
            ...
    categories:
      types:
        category:
          properties:
            ...
          persistence:
            ...