代码之家  ›  专栏  ›  技术社区  ›  steven

spring data elasticsearcher:如何使用路由删除spring data elasticsearch中的文档

  •  0
  • steven  · 技术社区  · 7 年前

    我的子文档映射是:

    {
    "_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查询和删除具有路由值的文档

    1 回复  |  直到 7 年前
        1
  •  -1
  •   steven    7 年前

    嗯,我找到了一种解决这个问题的方法,只需使用:

    org.elasticsearch.action.delete # "DeleteRequest"