Is there a way to merge two indices

Hi, I want to merge two indices( index 1, index 2) and make as one index( index 3),

For instance : let say, I have index 1 and index 2 have matching fields like ...

index 1 :(doc count 1)
	{
		"operation": "add",
		"time" : 1-4-2022,
	}
index 2:(doc count 2)
	{
		"operation" : "add",
		"time " : 21-10-2022,
		"description" : "hehhehehe"
	},
	{
		"operation" : "delete",
		"time " : 1-3-2022,
		"description" : "meh"
	}

now i want to create another index( index 3 ) that merges these two indices

index 3: (doc count 2)
	{
		"operation" : "add",
		"time " : 21-10-2022
	},
	{
		"operation" : "delete",
		"time " : 1-3-2022,
		"description" : "meh"
	}
Note : above example I matched the document using "operation" if the operation matches then it will update "time" field only(or the field that i want to update),
and if the "operation" field is now like above example "delete" then it will create a new document in index 3.

is there any way that I can achieve this ? (edited)

You can use the reindex API to achieve this. It will copy the documents from index 1 and index 2 into index 3, and you can then delete the old indices.

1 Like

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