spring-data-elasticsearcher:如何在spring data elasticsearcher中使用route删除文件

时间:2017-06-29 07:44:37

标签: spring-data-elasticsearch

我的子文档映射是:

{
"_index": "test-index",
"_type": "test_type",
"_id": "AVznf5cOTLguhbQOC8aV",
"_version": 1,
"_score": null,
"_routing": "1b973ddd-0aa9-4578-9bf9-74125a3c7r4d",
"_parent": "1b973ddd-0aa9-4578-9bf9-74125a3c7r4d",
"_source": {
"id": null,
"email": "test@hempel.com",
"actionDate": "2017-06-20T08:43:52.000Z",
"actionStatus": "SENT_SUCCESS",
"description": "",
"ip": "0.0.0.0",
"address": "",
"browser": null,
"os": "",
"taskId": "1b973ddd-0aa9-4578-9bf9-74125a3c7f4d",
"taskName": "007",
"actionStatusName": "SENT_SUCCESS",
"new": true
},
"sort": [
"test@hempel.com"
]
}

你可以看到它的子文档,所以每次我查询这样的文档时都会这样:

test_index/test_type/AVznWID-TLguhbQOC2Zt?routing=89293986-7d08-4e73-be1e-1ec9e136b440     /Get

好吧,所以删除会像这样:

test_index/test_type/AVznWID-TLguhbQOC2Zt?routing=89293986-7d08-4e73-be1e-1ec9e136b440     /delete

但问题是,如何查询和删除具有路由值的文档使用spring data elasticsearcher执行此作业: ElasticsearchTemplate

1 个答案:

答案 0 :(得分:-1)

好吧,我找到了解决这个问题的方法,只需使用:

org.elasticsearch.action.delete # "DeleteRequest"

在某些情况下,我们过分依赖该工具