I have quite a few data in my elasticSearch. One of the examples is,
{
"_index": "some_index",
"_type": "some_type",
"_id": "AWDpmuZ9u4O0tj_RL7Zr",
"_score": 1,
"_source": {
"avro_schema": "some_data",
"md_type": "AA"
}
I want to remove this object - "avro_schema": "some_data", .
Only if md_type is AA from all the documents.
I want to write a JAVA API which performs this action in elasticSearch.
As of now I have done this..
BoolQueryBuilder query = new BoolQueryBuilder();
query.should(QueryBuilders.boolQuery().must(QueryBuilders.existsQuery("md_type\":\"AA")));
UpdateByQueryRequestBuilder ubqrb = UpdateByQueryAction.INSTANCE.newRequestBuilder(client);
Script script = new Script("ctx._source.remove('avro_schema')");
BulkByScrollResponse response = ubqrb.script(script)
.filter(QueryBuilders.termQuery("md_type", "AA"))
.get();
By using partial-update you can update the document. https://www.elastic.co/guide/en/elasticsearch/reference/current/_updating_documents.html
More specifically for Java, https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-update.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.