Comments (11)
Hi @medcl, I'll raise an issue and see what happens.
Thank you for your time.
from elasticsearch-partialupdate.
hey,es already implemented a update api,you can check it out,
http://www.elasticsearch.org/guide/reference/api/update.html
elastic/elasticsearch#1583
from elasticsearch-partialupdate.
my sincere apologies that i missed out the new features. Closing the issue.
from elasticsearch-partialupdate.
Hi, any chance someone could point out how the documentation answers the question? I don't see any reference to nested types.
In PHP, I have:
$data = [
'note_link_id' => $link_id,
'user_id' => $this->flexi_auth->get_user_id(),
'creation' => date('Y-m-d\TH:i:s'),
'modification' => date('Y-m-d\TH:i:s'),
'from_asset' => $from,
'to_asset' => $to
];
... which, when sent to the model:
public function addAssetLinkData ($data, $params) {
try {
if (!isset($params['index']) || !isset($params['type']))
die ("Unable to add Elastic index for an Asset Link. Either index or type is not defined.");
$client = $this->_client;
$params['body']['doc']['links'] = [
$data
];
$responses = $client->update($params);
} catch (Exception $e) {
//die($e->getMessage());
}
}
... replaces any existing objects instead of appending to the links
nested type.
from elasticsearch-partialupdate.
PUT test/type1/1
{
"counter" : 1,
"tags" : ["red"]
}
GET test/type1/1
POST test/type1/1/_update
{
"doc" : {
"links" : {"url":"some url"}
}
}
from elasticsearch-partialupdate.
is that works for you?
from elasticsearch-partialupdate.
Hi @medcl, I'm using the official libraries for PHP, so no, that won't work for me as it's not PHP.
Also, that code isn't correct, as it should be:
PUT my_index/my_type/1
{
"group" : "fans",
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
However, with the correct formatting, it's the equivalent of what I'm doing, which — as I've explained — replaces any existing objects instead of appending to the links
nested type.
from elasticsearch-partialupdate.
Hi, @OctaneInteractive
Not check the PHP api, but should has a right way to achieve the RESTful API,
sorry i am a little confused, what you want is update the previous document and append a nested links objects, is that right?
from elasticsearch-partialupdate.
here is the restful example:
PUT my_index/my_type/1
{
"group" : "fans",
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
POST my_index/my_type/1/_update
{
"doc" : {
"links" : [{"url":"url1"},{"url":"url2"}]
}
}
GET my_index/my_type/1
the result is, seems as what you want
{
"_index": "my_index",
"_type": "my_type",
"_id": "1",
"_version": 3,
"found": true,
"_source": {
"group": "fans",
"user": [
{
"first": "John",
"last": "Smith"
},
{
"first": "Alice",
"last": "White"
}
],
"links": [
{
"url": "url1"
},
{
"url": "url2"
}
]
}
}
from elasticsearch-partialupdate.
Hi @medcl, as I explained, I'm using the official libraries, so using raw JSON is not feasible.
While those examples do work (using Postman, for example), the equivalent in PHP does not.
So either I'm doing something wrong, or the default behaviour of the PHP functions is to replace the objects in the nested type array, rather than appending to it.
from elasticsearch-partialupdate.
@OctaneInteractive
The php client should construct the json what i gave in the example,
if you are doing correctly, there should be PHP client's issue, can you confirm and raise a issue on that repo?
from elasticsearch-partialupdate.
Related Issues (4)
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-partialupdate.