elastic创建文档时报错 "{"error":"Incorrect HTTP method for uri [//product] and method [PUT], allowed: [POST]","status":405}"


代码

$params = [
        'index' => 'product',
        'body' => [
            'settings' => [
                'number_of_shards' => 1,
                'number_of_replicas' => 0
            ],
            'mappings' => [
                '_doc' => [
                    '_source' => [
                        'enabled' => true
                    ],
                    'properties' => [
                        'name' => [
                            'type' => 'text',
                            'analyzer' => 'ik_max_word',
                            'search_analyzer' => 'ik_max_word'
                        ],
                        'description' => [
                            'type' => 'text',
                            'analyzer' => 'ik_max_word',
                            'search_analyzer' => 'ik_max_word'
                        ]
                    ]
                ]
            ]
        ]
    ];
    $hosts = [
        'http://192.168.153.17:9200/',
    ];
    $client = ClientBuilder::create()
        ->setHosts($hosts)
        ->build();
// Create the index with mappings and settings now
    $response = $client->indices()->create($params);

  执行报错:

 

 

 

 

 检查代码

 

 发现是elastic地址多了斜杠、去除即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM