Problem with reindexing grand children documents

(photonic_world) #1

I have a 3 tiers of documents arranged as parent(A)-child(B)-grandchild(C).

This is done specifically, since the data on the child and grandchild keep adding up (and are never updated) and to make querying easier. This works perfectly fine.

Now the problem is:

  • I want to Re-index all three types of documents because I have realized the mappings could be more efficient.
  • I can reindex parent without any problem
  • I can reindex child since I have reference to parent id in the child document. I can use this to pass as argument for parent=<parent-id> while indexing.
  • The problem is with re-indexing child document (C), I will have to specify both parent Id of B and routing parameter as ID of A parent=<B-id>&routing=<A-id>. Since I only have reference to its parent id (B). I am looking for a way get ID of A to avoid fetching its parent (B) to reindex (C)

Any ideas? Any way I can fetch routing value of a document in C so that I can reuse it to re-index?

(photonic_world) #2

Found a way to do that.

Could get the fields by querying for _parent
GET /index/type/_search
"fields": [
"query": {
"match_all": {}

The above will fetch you parent id, routing id and the source.

(system) #3