简体   繁体   English

fos elasticabundle映射类型“数组”

[英]fos elasticabundle mapping type “array”

I have a doctrine array in column "tags" in table/entity "category". 我在表/实体“类别”的“标签”列中有一个学说数组。

FOS ElasticaBundle is up and working, and now I want to add the "tags" column to the search. FOS ElasticaBundle已启动并且正在运行,现在我想在搜索中添加“标签”列。

I cannot find any resources on how to set this up. 我找不到有关如何进行设置的任何资源。 Here is what I've tried and would like to do. 这是我尝试过并且想要做的。

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

I have three other types that use mapping type "nested" than run fine. 我还有其他三种使用映射类型“嵌套”的类型,它们运行起来还不错。 The array expected has no keys, so I don't know what to put down for properties. 期望的数组没有键,所以我不知道该为属性添加什么。

I'm getting this error 我收到这个错误

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

How do I set my mapping type "tags" as an array in Symfony2 using FOSElasticaBundle and where is this in any documentation? 如何使用FOSElasticaBundle在Symfony2中将映射类型“标签”设置为数组,这在任何文档中都在哪里?

The answer is 答案是

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

as described here 如此处所述

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

( working link, but idk if it's same page, someone feel free to edit and improve this answer ) https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-array-type.html (工作链接,但如果页面是idk,则为idk,有人可以随时编辑和改进此答案) https://www.elastic.co/guide/zh-cn/elasticsearch/reference/1.4/mapping-array-type.html

Came across the same question myself. 我自己遇到了同样的问题。 For the newest version of elasticsearch (v4) the type needs to be 'text': 对于最新版本的elasticsearch(v4),类型必须为“文本”:

type:
    category:
        mappings:
            tags:
                type: 'text'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM