0
votes

I index about 1,000,000 rows with elasticsearch and now want to index some other rows, but this error occurs:

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

I write php and this is my code:

<?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);

}
1
Specify the index name?sramalingam24
yes, i write elastic with php and this is my codeAli.Houshy

1 Answers

1
votes

You are putting the index, type and id inside the body object. It should be outside

$params = [
'index' => 'users',
'type' => 'user',
'id' => 'id',
'body' => ['name' => $row['name']....]
];

So on...