Как настроить отображение при индексации данных через массовый API в Elasticsearch-PHP?

Я пытаюсь следовать этот урок, и мне нужно сделать это на PHP, поэтому я должен использовать Elasticsearch-php. На этом конкретном этапе я пытаюсь настроить сопоставление для эластичного поиска, а также объемные данные индекса из .json файл. Поэтому я посмотрел на примеры Вот и [здесь] [3], и следующий мой код.

Проблема в том, что это дает мне

Elasticsearch PHP client created successfully!

Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL) #3 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/ in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610

и когда я закомментирую строку "dynamic" => "false", Я получил

Elasticsearch PHP client created successfully!

Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(O in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610

Что мне не хватает? Как мне это исправить?

<?phprequire_once("vendor/autoload.php");
use Elasticsearch\ClientBuilder;

$esClient = ClientBuilder::create()->build();

echo "Elasticsearch PHP client created successfully!<br>";//check

$indexParams = array();
$indexParams['index'] = "test_packets_index";
$indexParams['type'] = "testPacketsType";

$indexParams['body'] = [
'mappings' => [
"testPacketsType" => [

//"dynamic" => "false",
"properties" => ["timestamp" => [
"type" => "date"],"layers" => [
"properties" => [
"ip" => [
"properties" => [
"ip_ip_src" => [
"type" => "ip"],
"ip_ip_dst" => [
"type" => "ip"]
]
]
]
]]
]
]
];

$jsonFileHandle = fopen("packets.json", "r");
if ($jsonFileHandle) {
while (  ($line = fgets($jsonFileHandle))  !==  FALSE  ) {

if ( !($line == "") ) {
$indexParams['body'][] = json_decode($line, true);
}

}
}
fclose($jsonFileHandle);
#print_r($indexParams['body']);//check$indexingResponse = $esClient->bulk($indexParams);
echo "Result: "; print_r($indexingResponse); echo "<br>";//check?>
[3]: https: //www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_documents.html

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]