Delete field from the index

Hi,

I am having one index which consists 20 fields.The index having 2000 documents into it and I want to delete one field from that index. I don't want to update each document.
Can anyone please tell me how I can remove a field from the index? Is any query for that or any code example for that?

regards,
Suraj Dalvi

You can do probably a update by query with a script?
Not that "removing" a field does not remove the field from the mapping.

Anyway for 2000 documents it will be much much much faster, elegant, straightforward to just reindex in a new index.

Hi David,
Thanks for your reply, I want to delete a field from all documents which is a part of an array and I don't know the index of the field in that array. So how I delete such a field from all documents by using a script.
Please check following example:
[{
"name":"test",
"value":"John"
},{
"name":"test2",
"value":"Ram"
}]

Here I want to delete field with the name is "test"
Can you please help me into this?

I'm not a painless user TBH so I don't think i can help.
But I'd recommend reindexing anyway. That will be much easier IMO.

David is right, Reindex is better approach.

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