简体   繁体   中英

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.

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?

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

( 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

Came across the same question myself. For the newest version of elasticsearch (v4) the type needs to be 'text':

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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