无法识别的选项“类型” | FOS 弹性纤维交响乐团

发布于 2025-01-09 14:41:05 字数 2737 浏览 0 评论 0原文

我能够创建索引 1 by 1,但我的目的是拥有 1 个大索引和要搜索的子索引。 (我正在复制现有的应用程序,但升级依赖项)

Symfony:5.4* 低聚果糖-弹性:6.1 Elastic : 7*

这是我的错误消息,如果我将类型更改为属性,我会遇到类似的错误。我一整天都在尝试以不同的方式切换和缩进:

Unrecognized option "types" under "fos_elastica.indexes.app". Available options are "_id", "_routing", "_source", "analyzer", "client", "date_detection", "dynamic", "dynamic_date_formats", "dynamic_templates", "finder", "index_   
  name", "index_prototype", "indexable_callback", "numeric_detection", "persistence", "properties", "serializer", "settings", "use_alias".   

我做错了什么?

#app/config/config.yml
fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }

    indexes:
        app:
            settings:
                analysis:
                    analyzer:
                        fr:
                            tokenizer: standard
                            filter: [ lowercase, stop_fr, snowball_fr ]
                        autocomplete:
                            type: custom
                            tokenizer: whitespace
                            filter: [ lowercase, engram, elision ]
                        csv:
                            type: pattern
                            pattern: '\s*,\s*'
                            lowercase: false
                    filter:
                        snowball_fr:
                            type: "snowball"
                            language: "French"
                        stop_fr:
                            type: "stop"
                            stopwords: "_french_"
                        engram:
                            type: edge_ngram
                            min_gram: 2
                            max_gram: 15
            types:
                # ---------
                # USER
                # ---------
                user:
                    properties:
                        username: ~
                        email: ~
                        organization:
                            type: object
                            properties:
                                id: { index: true }
                                code: { index: true }
                                name:
                                    index: true
                                    type: text
                                    fields:
                                        source: { type: text, index: true }
                    persistence:
                        driver: orm # orm, mongodb, propel are available
                        model: App\Entity\User
                        provider: ~
                        listener: ~
                        finder: ~

I am able to create indexes 1 by 1 but my purpose is to have 1 big index with subindexes to search. (I am reproducing an existing app but upgrading dependencies)

Symfony : 5.4*
FOS-Elastica : 6.1
Elastic : 7*

This is my error message and if I change types to properties I have similar errors. I have been trying to switch and indent differently all day:

Unrecognized option "types" under "fos_elastica.indexes.app". Available options are "_id", "_routing", "_source", "analyzer", "client", "date_detection", "dynamic", "dynamic_date_formats", "dynamic_templates", "finder", "index_   
  name", "index_prototype", "indexable_callback", "numeric_detection", "persistence", "properties", "serializer", "settings", "use_alias".   

What am I doing wrong please ?

#app/config/config.yml
fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }

    indexes:
        app:
            settings:
                analysis:
                    analyzer:
                        fr:
                            tokenizer: standard
                            filter: [ lowercase, stop_fr, snowball_fr ]
                        autocomplete:
                            type: custom
                            tokenizer: whitespace
                            filter: [ lowercase, engram, elision ]
                        csv:
                            type: pattern
                            pattern: '\s*,\s*'
                            lowercase: false
                    filter:
                        snowball_fr:
                            type: "snowball"
                            language: "French"
                        stop_fr:
                            type: "stop"
                            stopwords: "_french_"
                        engram:
                            type: edge_ngram
                            min_gram: 2
                            max_gram: 15
            types:
                # ---------
                # USER
                # ---------
                user:
                    properties:
                        username: ~
                        email: ~
                        organization:
                            type: object
                            properties:
                                id: { index: true }
                                code: { index: true }
                                name:
                                    index: true
                                    type: text
                                    fields:
                                        source: { type: text, index: true }
                    persistence:
                        driver: orm # orm, mongodb, propel are available
                        model: App\Entity\User
                        provider: ~
                        listener: ~
                        finder: ~

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不交电费瞎发啥光 2025-01-16 14:41:05

因此,我也在弄清楚如何处理与您相同的问题,并且我确实确认许多文档和博客文章都使用您发布的配置结构。然而,当我回到捆绑包的 v6.1 文档时,我 发现了这个

动态模板

动态模板允许定义映射模板
动态引入字段/对象时将应用
发生了。

文档

<前><代码>fos_elastica:
指标:
用户:
动态模板:
我的_模板_1:
匹配:苹果_*
映射:
类型: 浮动
我的_模板_2:
匹配: *
match_mapping_type:文本
映射:
类型:关键字
特性:
用户名:{ 类型:文本 }

因此,在您的情况下,工作配置将如下所示:

#app/config/config.yml
fos_elastica:
  clients:
    default: { host: localhost, port: 9200 }

  indexes:
    user:
      settings:
        analysis:
          analyzer:
            fr:
              tokenizer: standard
              filter: [ lowercase, stop_fr, snowball_fr ]
            autocomplete:
              type: custom
              tokenizer: whitespace
              filter: [ lowercase, engram, elision ]
            csv:
              type: pattern
              pattern: '\s*,\s*'
              lowercase: false
          filter:
            snowball_fr:
              type: "snowball"
              language: "French"
            stop_fr:
              type: "stop"
              stopwords: "_french_"
            engram:
              type: edge_ngram
              min_gram: 2
              max_gram: 15
      properties:
        username: ~
        email: ~
        organization:
          type: object
          properties:
            id: { index: true }
            code: { index: true }
            name:
              index: true
              type: text
              fields:
                source: { type: text, index: true }
      persistence:
        driver: orm # orm, mongodb, propel are available
        model: App\Entity\User
        provider: ~
        listener: ~
        finder: ~

So I was also figuring out how to deal with the same issue as yours, and I do confirm lot of the docs and blogposts out there use the config struture you posted. However when I went back to the v6.1 documentation of the bundle I found this:

Dynamic templates

Dynamic templates allow to define mapping templates
that will be applied when dynamic introduction of fields / objects
happens.

Documentation

fos_elastica:
    indexes:
        user:
            dynamic_templates:
                my_template_1:
                    match: apples_*
                    mapping:
                        type: float
                my_template_2:
                    match: *
                    match_mapping_type: text
                    mapping:
                        type: keyword
            properties:
                username: { type: text }

So in your case a working config would look like:

#app/config/config.yml
fos_elastica:
  clients:
    default: { host: localhost, port: 9200 }

  indexes:
    user:
      settings:
        analysis:
          analyzer:
            fr:
              tokenizer: standard
              filter: [ lowercase, stop_fr, snowball_fr ]
            autocomplete:
              type: custom
              tokenizer: whitespace
              filter: [ lowercase, engram, elision ]
            csv:
              type: pattern
              pattern: '\s*,\s*'
              lowercase: false
          filter:
            snowball_fr:
              type: "snowball"
              language: "French"
            stop_fr:
              type: "stop"
              stopwords: "_french_"
            engram:
              type: edge_ngram
              min_gram: 2
              max_gram: 15
      properties:
        username: ~
        email: ~
        organization:
          type: object
          properties:
            id: { index: true }
            code: { index: true }
            name:
              index: true
              type: text
              fields:
                source: { type: text, index: true }
      persistence:
        driver: orm # orm, mongodb, propel are available
        model: App\Entity\User
        provider: ~
        listener: ~
        finder: ~
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文