“ fos_elastica.indexes.app.types.user”下的无法识别的选项“映射”

时间:2019-01-14 10:02:53

标签: symfony elasticsearch elastica

我将symfony与fos elastica捆绑包一起使用。我正在尝试像本教程https://www.codevate.com/blog/14-implementing-search-as-you-type-autocomplete-with-elasticsearch-and-symfony中那样添加映射,但是出现此错误:

Unrecognized option "mappings" under "fos_elastica.indexes.app.types.user"

这是我的配置:

# Read the documentation: https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md
fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
#    indexes:
#        app: ~
    indexes:
        app:
            client: default
            settings:
              index:
                analysis:
                  analyzer:
                    name_analyzer:
                      type: custom
                      tokenizer: standard
                      filter: [standard, lowercase, asciifolding, elision]
            types:
                user:
                    properties:
                        username: ~
#                    mappings:
#                        email: ~
                    mappings:
                      username:
                        type: completion
                        analyzer: name_analyzer
                        search_analyzer: name_analyzer
                        payloads: true
                    persistence:
                        # the driver can be orm, mongodb, phpcr or propel
                        # listener and finder are not supported by
                        # propel and should be removed
                        driver: orm
                        model: App\Entity\User
                        provider: ~
                        listener: ~
                        finder: ~

1 个答案:

答案 0 :(得分:1)

fos_elastica配置中没有“映射”属性。您可以使用以下命令列出所有可能的配置属性:

git

尝试将php bin/console config:dump-reference fos_elastica 更改为mappings,并在上面的配置中删除空的properties键。

如果遇到类似的错误,请尝试使用配置参考或官方文档:

https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/v5.0.3/doc/types.md