php - 使用 Elastica 库删除 ElasticSearch 中的文档

标签 php magento search elasticsearch indexing

我有 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/

相关文章:

php - Magento 使用集合进行 (OR)

php - 如何防止我的网站页面通过 iFrame 的第 3 方网站框架加载

php - 无法保存库存项目。请再试一次。 Magento 2.4.0

javascript - Magento 产品页面 - 显示缺货的相关产品

mysql - 如何使用 codeigniter 在多个表中进行搜索?

使用 FileFilter 的 JavaFX 过滤器 ListView 文件元素

php - WP_Query 在查询中传递术语

php - 如何在没有表单的情况下发布到数据库 php mysql html

php - 如何通过 SOAP api 更新团体价格

elasticsearch - 在Liferay中搜索