2

我在表/实体“类别”的“标签”列中有一个学说数组。

FOS ElasticaBundle 已启动并正在工作,现在我想将“标签”列添加到搜索中。

我找不到任何有关如何设置的资源。这是我尝试过并想做的事情。

  search:
        client: default
        types:
            category:
                mappings:
                    displayName: ~
                    searchRef: ~
                    tags:
                        type: 'array'
                persistence:
                    driver: orm
                    model: SC\ProviderBundle\Entity\Category
                    provider: ~
                    listener: ~
                    finder: ~

我有其他三种类型使用“嵌套”映射类型而不是正常运行。预期的数组没有键,所以我不知道该为属性放下什么。

我收到此错误

[Elastica\Exception\ResponseException]
 MapperParsingException[mapping [category]]; nested: MapperParsingException[No handler for type [array] declared on field [tags]];

如何使用 FOSElasticaBundle 在 Symfony2 中将我的映射类型“标签”设置为一个数组,这在任何文档中的什么位置?

4

2 回答 2

4

答案是

type:
    category:
        mappings:
            tags:
                type: 'string'

如此处所述

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-array-type.html

(工作链接,但如果是同一页,请随时编辑和改进此答案) https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-array-type.html

于 2014-06-20T14:35:14.710 回答
3

我自己也遇到过同样的问题。对于最新版本的 elasticsearch (v4),类型需要是“文本”:

type:
    category:
        mappings:
            tags:
                type: 'text'
于 2017-04-12T12:10:30.027 回答