I have been playing around with parent/child documents lately and the
following question came up: is it possible to change the parent of a
document?
Say, I have the following two documents:
/person/1 -d {}
/person/2 -d {}
and an asset:
/asset/3?parent=1
is it possible to change the parent to "2"?
Reindexing with parent 2 only seems to introduce a second document. (which
makes sense, as parent doubles as routing parameter)
I tried setting the _parent field directly to 2 in multiple ways (index,
update with script), but it somehow seemed to render elasticsearch
inconsistent (e.g. parents were still querying their old childs on
has_child).
Is this possible or supported? Or do I have to delete the old document and
index a new one with the same source, but different _parent settings?
I don't believe it is without creating a new document and deleting the old
one, that you can move parents. Most modification actions imply a
recreation of a document, and not an update.
I have been playing around with parent/child documents lately and the
following question came up: is it possible to change the parent of a
document?
Say, I have the following two documents:
/person/1 -d {}
/person/2 -d {}
and an asset:
/asset/3?parent=1
is it possible to change the parent to "2"?
Reindexing with parent 2 only seems to introduce a second document. (which
makes sense, as parent doubles as routing parameter)
I tried setting the _parent field directly to 2 in multiple ways (index,
update with script), but it somehow seemed to render elasticsearch
inconsistent (e.g. parents were still querying their old childs on
has_child).
Is this possible or supported? Or do I have to delete the old document and
index a new one with the same source, but different _parent settings?
imo, it's not possible, because a child document is stores on the same
shard as its parent
On Thursday, June 14, 2012 6:00:09 PM UTC+2, Patrick Ancillotti wrote:
I don't believe it is without creating a new document and deleting the old
one, that you can move parents. Most modification actions imply a
recreation of a document, and not an update.
I have been playing around with parent/child documents lately and the
following question came up: is it possible to change the parent of a
document?
Say, I have the following two documents:
/person/1 -d {}
/person/2 -d {}
and an asset:
/asset/3?parent=1
is it possible to change the parent to "2"?
Reindexing with parent 2 only seems to introduce a second document.
(which makes sense, as parent doubles as routing parameter)
I tried setting the _parent field directly to 2 in multiple ways (index,
update with script), but it somehow seemed to render elasticsearch
inconsistent (e.g. parents were still querying their old childs on
has_child).
Is this possible or supported? Or do I have to delete the old document
and index a new one with the same source, but different _parent settings?
thanks for the answers. So my suspicion was right. I was aware that this
would be a special operation, as the child would have to be moved to the
new shard.
I have an additional question for my future mental model: can I safely
assume that documents never "travel" shards and have to be moved by hand?
thanks for the answers. So my suspicion was right. I was aware that this
would be a special operation, as the child would have to be moved to the
new shard.
I have an additional question for my future mental model: can I safely
assume that documents never "travel" shards and have to be moved by hand?
We have also experienced this issue where we are now using parent/child
documents. We are using 0.90.5 version.
Our application requires that we re-assign a child to a new parent from
time to time and we discovered that without first deleting the child with
the old parent, two documents with the same _id but different parents can
be in the index because the parents are on different shards. Does anyone
know if it is possible to reassign a child to a new parent without first
deleting might something available in newer versions? It seems reasonable
that a document can be updated by it's canonical document id (_id), without
having to aware of the subtleties of sharding?
On Thursday, June 14, 2012 11:39:56 AM UTC-4, Florian Gilcher wrote:
Hi,
I have been playing around with parent/child documents lately and the
following question came up: is it possible to change the parent of a
document?
Say, I have the following two documents:
/person/1 -d {}
/person/2 -d {}
and an asset:
/asset/3?parent=1
is it possible to change the parent to "2"?
Reindexing with parent 2 only seems to introduce a second document. (which
makes sense, as parent doubles as routing parameter)
I tried setting the _parent field directly to 2 in multiple ways (index,
update with script), but it somehow seemed to render elasticsearch
inconsistent (e.g. parents were still querying their old childs on
has_child).
Is this possible or supported? Or do I have to delete the old document and
index a new one with the same source, but different _parent settings?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.