elasticsearch Fatal error: Uncaught Elasticsearch\Common\Exceptions\RuntimeException: index is required for Index in
elasticsearch Fatal error: Uncaught Elasticsearch\Common\Exceptions\RuntimeException: index is required for Index in
我用 elasticsearch 索引了大约 1,000,000 行,现在想索引其他一些行,但是出现了这个错误:
Fatal error: Uncaught
Elasticsearch\Common\Exceptions\RuntimeException: index is required
for Index in
C:\wamp64\www\myProject...\elastic\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Endpoints\Index.php
on line 55
我写 php 这是我的代码:
<?php
/*
* index document module
*/
public function insert_node ($id) {
// 1 - set connection
// code
// 2 - get data from mysql query
// code
// 3 - assign data to $row array in foreach
// code
// 4 - set $params array for index
$params['body'][] = [
'_index' => 'users',
'_type' => 'user'
];
$params['body'][] = [
'id' => $row['id'],
'name' => $row['name'],
'phone' => $row['phone'],
'province' => $row['province'],
'credit' => $row['credit'],
...
];
// 5 - index data
$responses = $client -> index ($params);
}
您正在将索引、类型和 ID 放入正文对象中。应该在外面
$params = [
'index' => 'users',
'type' => 'user',
'id' => 'id',
'body' => ['name' => $row['name']....]
];
等等...
我用 elasticsearch 索引了大约 1,000,000 行,现在想索引其他一些行,但是出现了这个错误:
Fatal error: Uncaught Elasticsearch\Common\Exceptions\RuntimeException: index is required for Index in C:\wamp64\www\myProject...\elastic\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Endpoints\Index.php on line 55
我写 php 这是我的代码:
<?php
/*
* index document module
*/
public function insert_node ($id) {
// 1 - set connection
// code
// 2 - get data from mysql query
// code
// 3 - assign data to $row array in foreach
// code
// 4 - set $params array for index
$params['body'][] = [
'_index' => 'users',
'_type' => 'user'
];
$params['body'][] = [
'id' => $row['id'],
'name' => $row['name'],
'phone' => $row['phone'],
'province' => $row['province'],
'credit' => $row['credit'],
...
];
// 5 - index data
$responses = $client -> index ($params);
}
您正在将索引、类型和 ID 放入正文对象中。应该在外面
$params = [
'index' => 'users',
'type' => 'user',
'id' => 'id',
'body' => ['name' => $row['name']....]
];
等等...