Can I delete a field of a doc?


(za) #1

I want to delete a field of a doc, I tried some ways but failed. Is there a query DSL or api I can use?


(David Pilato) #2

Just send a new version of your doc without the field...


(za) #3

Thanks a lot. If there is no other way to implement it. I will try this way.


(David Pilato) #4

It's the easiest way. Is there anything wrong with that method from your point of view?


(Nik Everett) #5

You could use the update API with an update script. This eliminates a round trip at the cost of having to deal with scripting.


(za) #6

I worry about the conflict of the update, may be some threads update the doc at the same time. But It seems this is the only way. I will fetch the old doc first, remember the old version, and post the new doc without the field I want to remove, and then check the version returned.


(David Pilato) #7

You can use versionning: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-versioning


(system) #8