不能在放置映射请求中提供类型,除非include_type_name参数在具有弹性搜索的流明中设置为true 7.6.2

问题描述 投票:0回答:1

我正在使用https://github.com/basemkhirat/elasticsearch软件包。

es.php文件中,我在indices >>]下

'indices' => [
        'media' => [
            'settings' => [
                'number_of_shards' => 2,
                'number_of_replicas' => 2,
                'analysis' => [
                    'filter' => [
                        'custom_english_stemmer' => [
                            'type' => "stemmer",
                            'name' => "english"
                        ],
                        "english_stop" => [
                            'type' => "stop",
                            'stopwords' => "_english_"
                        ]
                    ],
                    "analyzer" => [
                        'custom_lowercase_analyzer' => [
                            // 'type' => 'custom',
                            'tokenizer' => 'standard',
                            'filter' => [
                                'lowercase',
                                'english_stop',
                                "custom_english_stemmer"
                            ]
                        ]
                    ]
                ]
            ],
            'mappings' => [
                'properties' => [
                    'id' => [
                        'type' => 'long',
                        'index' => false,
                        'doc_values' => false,
                    ],
                    'title' => [
                        'type' => 'text',
                        "analyzer" => 'custom_lowercase_analyzer'
                    ]
                ]
            ]
        ]
    ]

现在执行php artisan es:indices:create时会创建设置,但映射失败并显示错误消息。

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
  },
  "status": 400
}

enter image description here

如何解决此问题

我正在使用https://github.com/basemkhirat/elasticsearch软件包。在es.php文件中,我有以下索引'indices'=> [''media'=> ['settings'=> ['...

php elasticsearch lumen elasticsearch-7
1个回答
0
投票

您正在创建索引代码中提供类型,因为不建议使用类型,请从索引中删除media类型,有关更多信息,请参见the removal of types。>

[请注意,在Elasticsearch 7.X中,您仍然可以通过具有types参数来获得include_type_name的方法,但由于在即将发布的Elasticsearch 8.X中将完全删除types,因此它不是首选方法。

为了在您的情况下使用具有自定义type的索引来创建索引,例如media,您需要将include_type_name=true传递给索引创建,模板和映射API,如this official ES blog中所述

© www.soinside.com 2019 - 2024. All rights reserved.