我在java中有一个项目,我使用弹性搜索2.3.3索引数据.索引有两种类型.
我的索引文档看起来像:
{
"took": 10,"timed_out": false,"_shards": {
"total": 1,"successful": 1,"Failed": 0
},"hits": {
"total": 3,"max_score": 1,"hits": [
{
"_index": "test_index","_type": "movies","_id": "uReb0g9KSLKS18sTATdr3A","_score": 1,"_source": {
"genre": "Thriller"
}
},{
"_index": "test_index","_type": "drama","_id": "cReb0g9KSKLS18sTATdr3B","_source": {
"genre": "SuperNatural"
}
},{
"_index": "index1","_id": "cReb0g9KSKLS18sT76ng3B","_source": {
"genre": "Romance"
}
}
]
}
}
例如: – 从上面的doc,我想删除名为“test_index”的索引并输入“drama”.
所以结果应该是这样的:
{
"took": 10,"hits": {
"total": 2,"_source": {
"genre": "Romance"
}
}
]
}
}
解决方案:
client.admin().indices().delete(new DeleteIndexRequest(“test_index”).actionGet();
但它删除名为“test_index”的两个索引
DELETE / test_index / drama
它给出了错误:找不到uri [/ test_index / drama]和方法[DELETE]的处理程序
DELETE / test_index / drama / _query?q = _id:*& analyze_wildcard = true
它也行不通.
当我在那时触发删除索引请求时,我们不知道索引的id,我只能按名称和类型删除索引.
如何使用java api删除所需的索引?
最佳答案
原文链接:https://www.f2er.com/spring/432380.html