使用FosElasticaBundle索引外键标签

时间:2017-12-04 10:38:25

标签: symfony elasticsearch foselasticabundle

当我索引我的关系数据库(Postgresql)时,我想得到外键id的字符串值intead(重新创建两个表personn和country之间的关系..) 我希望在fos_elastica.yml映射文件中执行此操作

示例:

fos_elastica:
    clients:
        default: { host: %elastic_host%, port: %elastic_port% }
    indexes:
        ex_app:
            client: default
            types:
                personn:
                    mappings:
                        id:
                            type: integer
                        name:
                            type: text
                            boost: 5
                        firstname:
                            type: text
                            boost: 3
                        dateofbirth:
                            type: date
                        country:
                            type: integer
                    persistence:
                        driver: orm
                        model: AppBundle\Entity\Personn
                        finder: ~
                        provider: ~
                        listener: ~

我想通过输入国家名称而不是国家/地区ID来找到此人。

1 个答案:

答案 0 :(得分:0)

我很确定你应该使用“嵌套”:

fos_elastica:
        clients:
            default: { host: %elastic_host%, port: %elastic_port% }
        indexes:
            ex_app:
                client: default
                types:
                    personn:
                        mappings:
                            id:
                                type: integer
                            name:
                                type: text
                                boost: 5
                            firstname:
                                type: text
                                boost: 3
                            dateofbirth:
                                type: date
                            country:
                                type: "nested"
                                 properties:
                                 id: 
                                    type : integer
                                 label: 
                                    type: text 
                        persistence:
                            driver: orm
                            model: AppBundle\Entity\Personn
                            finder: ~
                            provider: ~
                            listener: ~