Javascript API でdeleteByQuery()を使用して、 というインデックスからいくつかのドキュメントを削除したいと考えていますpeople
。
これはAWS Elastic Search Serviceのバージョン 5.1 であることに注意してください。
インデックス マッピングは次のようになります。
"people": {
"mappings": {
"person": {
"properties": {
"name": {
"type": "string"
},
"parent_id": {
"type": "long"
},
"query": {
"properties": {
"match": {
"properties": {
"parent_id": {
"type": "long"
}
}
},
"term": {
"properties": {
"parent_id": {
"type": "long"
}
}
}
}
}
}
}
}
}
そして、次のように構成された検索クエリ:
query: {
term: {
parent_id: 1
}
}
次のように応答します。
"hits": {
"total": 1,
"max_score": 10.135444,
"hits": [
{
"_index": "people",
"_type": "person",
"_id": "AVp6EDRVm933W5mwl4O9",
"_score": 10.135444,
"_source": {
"name": "Bob",
"parent_id": 1
}
}
]
}
そこで、JS API のドキュメントを使用して、以下を作成しました。
const elasticsearch = require('elasticsearch')
function deletePeople (parentId) {
new elasticsearch
.Client({ host: 'es.host.domain' })
.deleteByQuery({
index: 'people',
type: 'person',
body: {
query: {
term: {
parent_id: parentId
}
}
}
}, function afterDeletingPeople (error, response) {
if (error) {
return console.log("deletePeople :: Error :: ", error);
}
else {
return console.log("deletePeople :: Response :: ", response);
}
});
};
deletePeople(1);
次のような応答が得られます。
info: deletePeople :: Response :: { _index: 'people',
_type: 'person',
_id: '_delete_by_query',
_version: 30,
_shards: { total: 2, successful: 1, failed: 0 },
created: false }
これは希望に満ちているように見えますが、実際にインデックスから削除された人はいません。match
代わりにクエリを使用しようとしterm
ましたが、同じことを行います。
現在、私の関数は人を削除していないので、これでどこが間違っているのか誰かが提案できますか? ティア!