tanimoto
(tanimoto)
December 28, 2016, 6:33am
1
my php file is as below.
<?php
require_once '/usr/local/bin/composer/vendor/autoload.php';
$host = ["http://localhost:9200"];
$client = Elasticsearch\ClientBuilder::create()->setHosts($host)->build();
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => '1'
'body' => [
'doc' => [
'new_field' => 'abc'
]
]
];
$response = $client->update($params);
Can I update/delete/get/index multiple data at once?
Or should I loop this operation by PHP and execute $client->update($params);
as many as needed??
It is not described here
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_updating_documents.html
dadoonet
(David Pilato)
December 28, 2016, 6:47am
2
BULK API is the way to go. Much more efficient.
tanimoto
(tanimoto)
December 28, 2016, 6:54am
3
you mean, PHP client can't do it?
tanimoto
(tanimoto)
December 28, 2016, 7:12am
4
PHP client sounds bit confusing sorry.
I mean, $client->update($params);
method can't update multiple data at once?
dadoonet
(David Pilato)
December 28, 2016, 7:31am
5
tanimoto
(tanimoto)
December 28, 2016, 7:34am
6
Ah, bulk api can be used through PHP client!!
Thanks!!
tanimoto
(tanimoto)
December 28, 2016, 9:50am
7
But bulk seems to unable to update document partially.
It reindex whole document.
It used to have updateByQuery but it was removed from elasticsearch-php 5.0.
Is there any other way to update multiple document specific fields?
dadoonet
(David Pilato)
December 28, 2016, 10:23am
8
bulk API supports update requests .
about updateByQuery in PHP, I have no idea. I think it has not been added probably as it's new but I might be wrong.
However, I guess you can perform any low level HTTP REST call using the PHP client, so may be you can do it yourself?
See REST API doc: https://www.elastic.co/guide/en/elasticsearch/reference/5.1/docs-update-by-query.html
HTH
tanimoto
(tanimoto)
December 28, 2016, 10:33am
9
Yeah, this is the solution at the moment creating HTTP REST by my self.
I will rethink how to achieve it again.
Anyway, thanks a lot.
system
(system)
Closed
January 25, 2017, 10:33am
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.