如何处理已删除的文档

如何处理已删除的文档

本文介绍了Solr DIH-如何处理已删除的文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的Web应用程序进行Solr驱动的搜索,我发现最好使用DataImportHandler通过数据库处理与应用程序的同步.我喜欢只检查last_updated_date字段的优雅之处.好东西.但是,我不知道如何使用这种方法来处理删除文档.从我的角度来看,我有2种选择.我可以在删除文档时从客户端向Solr发送明确的消息,也可以添加已删除"标志并将对象保留在数据库中,以便Solr会注意到文档已更改,现在已删除" ."我可以添加一个查询过滤器,该查询过滤器将忽略带有Deleted标志的结果,但是将所有已删除的文档包括在Lucene索引中似乎效率不高.其他人做什么?

I'm playing around with a Solr-powered search for my webapp, and I figured it'd be best to use the DataImportHandler to handle syncing with the app via the database. I like the elegance of just checking the last_updated_date field. Good stuff. However, I don't know how to handle deleting documents with this approach. The way I see it, I've got 2 choices. I could either send an explicit message to Solr from the client when a document is deleted, or I could add a "deleted" flag and leave the object in the database, so that Solr will notice that the document has changed and is now "deleted." I could add a query filter that would disregard results with the deleted flag, but it seems inefficient to include all the deleted documents in the Lucene index. What do other folks do?

推荐答案

这些是您的选择:

  • 使用 DIH特殊命令 $ deleteDocById或$ deleteDocByQuery(需要Solr 1.4 +)
  • 在导入之前,使用DIH的 clean参数删除整个索引.
  • 使用 preImportDeleteQuery 定义要在导入之前清除的内容. (需要Solr 1.4 +)
  • 使用数据库触发器而不是DIH来管理索引的更新.
  • 如果您使用某种ORM,请使用其拦截功能代替DIH.例如,您可以使用休眠事件在更新,插入或删除时更新索引.
  • Use DIH special commands $deleteDocById or $deleteDocByQuery (requires Solr 1.4+)
  • Use the clean parameter of DIH to delete the whole index before importing.
  • Use preImportDeleteQuery to define what's going to be cleaned up before importing. (requires Solr 1.4+)
  • Use database triggers instead of DIH to manage updating the index.
  • If you're using some sort of ORM use its interception capabilities instead of DIH. For example you can use hibernate events to update the index on update, insert or delete.

这篇关于Solr DIH-如何处理已删除的文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:20