Reindex API - Reference doc

Hi,

I'm trying to use the Reindex API to update an existing document, but I can't seem to find how to increment the value of the existing field with the value of the new document.

I don’t understand. When you reindex, you reindex an old document. What do you mean by referencing the value of a new document?

Forget it. I though you can also update the existing doc when using the Reindex API, but apparently you can't.

But you can.

You can add an ingest pipeline with a painless script which edits the old document before reindexing it.

Hmm thats a really good point. Can i also use that for upserting when the doc doesn't exist?

I don't see where in the docs of the script processor I can access both the existing doc and the new doc

I'm actually pretty sure you can't do it, as the ingestion phase can be located to different nodes which don't hold the data.

That’s confusing. Reindex API is reindexing documents from an existing index. So the document exists for sure.

The “new” doc is the existing doc. I think you are not understanding what reindex api is.

I understand.

Its "re-indexing" existing documents from 1 index to another.

But there can be a situation where you have 3 documents:
Given you are re-indexing from index1 to index2:

  1. the original document in index1
  2. an existing document in index2
  3. the re-indexed document that is being copied from index1 to index2

If I set the ctx._id of the soon-to-be-reindexed document to the same as an existing one, it will override the older doc with this new one.

My question is, can I use the same Reindex API to update the old document instead of overriding it?

I see.

No it will override.

But if you have a document

{
  “foo”: “bar”
}

And reindex it, it will become:

{
  “foo”: “bar”
}

You can apply an ingest script if you wish so you document can become:

{
  “foo”: “barbaz”,
  “age”: 20
}

If you wish

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.