我有 Elastica 库并在我的项目中实现了 ElasticSearch。 我想从索引中删除文档。 如何使用 elastica 在 elasticsearch 中按 id 删除文档? 我尝试了多种解决方案,但仍然无法正常工作! 时间差
最佳答案
要通过 id 删除文档,您可以使用 deleteByQuery() 函数,它是 elastica 中的索引函数,因此您可以像这样使用它:
$matchPhraseQuery = new MatchPhrase("_id", /*id of document you want to delete*/);
$client = new Client(/*your client config*/);
$index = $client->getIndex("/*Your index name*/");
$index->deleteByQuery($matchPhraseQuery);
关于php - 使用 Elastica 库删除 ElasticSearch 中的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42525534/