Hi
is it possible to delete a field in all the document of an index if he match to a regex ?
Thanks and Regards
Hi
is it possible to delete a field in all the document of an index if he match to a regex ?
Thanks and Regards
Sounds like a work for Update By Query with a regex query.
Please note that in Elasticsearch it's not possible to delete a field. Operations are atomic on the document level, so deleting a field is basically deleting a document in reindexing the same document without the field.
Thanks for the quick response,
I've read the link you give me, but the thing that I don't see how to do is to perform the regex not on a specific value of a field but on the field name.
by example : if I want to remove all the fields that begin by extra_data_other
thanks
This will reindex all documents from the index src
to the index dst
while removing all fields that start with b
:
PUT src/doc/1
{
"foo": 1,
"bar": 2,
"baz": 3
}
POST _reindex
{
"source": {
"index": "src"
},
"dest": {
"index": "dst"
},
"script": {
"source": "ctx._source.keySet().stream().filter(s -> s.startsWith('b')).collect(Collectors.toList()).forEach(k -> ctx._source.remove(k))",
"lang": "painless"
}
}
Ho thank you ,
I miss that from the painless doc
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.