Comments (8)
There are, please see the documentation here:
Currently, bulk requests must follow the Elasticsearch Bulk format. In the future, I would like to provide a helper method that builds the bulk format for you (because the syntax is kinda gross)
from elasticsearch-php.
It is terrible :(
from elasticsearch-php.
The bulk syntax was designed for performance, not developer friendliness.
Building the syntax algorithmically is very simple. And honestly, that is all a "helper" method would be doing. Here is some (untested) code to illustrate how simple it is:
//All your docs here
$myDocs = array( ... );
// This will hold the final bulk
$bulkString = '';
// For brevity, assume docs don't have IDs
$action = array(
"index" => new \stdClass()
);
$actionString = json_encode($action);
foreach ($myDocs as $doc) {
$bulkString .= "$actionString\n";
$bulkString .= json_encode($doc) . "\n";
}
$params['index'] = 'my_index';
$params['type'] = 'my_type';
$params['body'] = $bulkString
$ret = $client->bulk($params);
from elasticsearch-php.
Thank you @polyfractal . Have you idea when It will enter in the main code?
I will really try this. I want a bulk exactly for performace, but I don't think that it need be ugly.
from elasticsearch-php.
Unsure. There are a few bigger issues that I need to deal with first, not quite sure how long they will take.
Could you open a new ticket about the Bulk Helper method so that I don't forget?
from elasticsearch-php.
Sure! After the lunch!
from elasticsearch-php.
A fork (without unit tests) will be acceptable?
from elasticsearch-php.
Do you mean a Pull Request for the bulk helper function?
If yes, it should be implemented in a class outside of the client. The client is supposed to be entirely unopinionated...just a simple translation from the Elasticsearch API to a PHP API. I would recommend adding a new Helper
class that lives in /src/Elasticsearch/Helper.php
. Then users could do something like:
$helper = new Elasticsearch\Helper();
$helper->bulk()->index($myDoc);
I think there are a few functional requirements to make it useful:
- index()
- update()
- delete()
- create()
- setIndex()
- setType()
- setBulkDocSize()
- setBulkPhysicalSize()
- setBulkTimeout()
- flushBulk()
The bulk helper should also (probably?) return a special bulk object which facilitates working with the results (instead of just an array), so that it could have methods like:
- getSucceeded()
- getFailed()
- getAll()
- retryFailed()
You can see that the helper has quite a bit of functionality to make it really useful. All pretty simple, but a decent amount of code.
Test would be preferred before merging, but we can work on tests after some code has been produced.
from elasticsearch-php.
Related Issues (20)
- Path in hosts configuration is ignored HOT 2
- check the index exsists ,it have a error HOT 1
- Connecting to Elasticsearch v8.x using the v7.17.x client HOT 1
- Received a 403 Forbidden error when attempting to index HOT 1
- `Response\Elasticsearch::offsetGet()` return type declaration HOT 2
- Need a new Release 6.8.3 HOT 4
- ServerError was not handled correctly. HOT 2
- Add support for Elasticsearch with Bulk API and data stream HOT 1
- How to pass specific characters password to ElasticSearch through Sulu/ArticleBundle HOT 5
- [Request feedback] Looking for feedback about the UX experience
- Calling static trait method ... is deprecated HOT 1
- Inquiries about version use HOT 2
- [Proposal] Add a mapTo(class) function for map ES|QL response into objects HOT 1
- Why Can't I update the mapping with Laravel Scout? HOT 1
- 使用PHP GET方法,不能获取到文档内容 HOT 4
- please help me change the php code from pagination from + size to search_after HOT 5
- failed to get the last sort using search_after HOT 1
- Add OpenTelemetry support HOT 1
- will elasticsearch-php pre-open the urls on the page when I visit it? HOT 3
- "Type: illegal_argument_exception Reason: "Fielddata is disabled on [pageCategory] in [elastic_web_index]. Text fields are not optimised for operations that require per-document field data like aggregations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-php.