Elasticsearch Update Doc String Replacement


(Adityo Setyonugroho) #1

I have some documents on my Elasticsearch. I want to update my document contents by using String Regexp.

For example, I would like to replace all http words into https words with in a paragraph, is it possible ?

Thank You


(David Pilato) #2

May be with a painless script using the update API?
Or with the reindex API.

How many documents do you need to update ?


(Adityo Setyonugroho) #3

Thank you for your reply.

I tried to construct the script but no idea for now.

I want to update all documents within my index. Here is the sample data struct:
{
"id" : 1,
"content" : "Test Test Test",
"ImageURL" : "http://www.image.com/test/image.jpg"
}

For example, I want to change all http into https or change the domain for all documents.

Is there any update script that can update this scheme ? or I just create new index with the data ?

It would be nice if I can do update instead of reimport / make another index.

Thank You


(David Pilato) #4

To update 100% of the data, aka reindex, I'd use the reindex API with an ingest script processor.

If you have the source of the data elsewhere, may be it can be easier for you to do this transformation on your application side?

If not, reindex API is the way to go IMO.


(Adityo Setyonugroho) #5

Thanks for your reply.

If I use reindex API, do I need to reimport data again ?

I will use transformation by using application if I am stuck with elastic natives API haha.


(David Pilato) #6

If I use reindex API, do I need to reimport data again ?

Hmmm. Not sure I understand it.
I'd say "no".

Reindex API reads data from elasticsearch using _source field and reindex all in another index.


(system) #7

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