如何使Lucene索引与Mysql数据库保持同步? [英] How to keep Lucene index synchronized with Mysql database?

查看:982
本文介绍了如何使Lucene索引与Mysql数据库保持同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试利用Lucene在我的应用程序中开发全文搜索,这需要基于我的mysql数据库构建索引。我想知道如何保持这些索引与db同步?
我提出了各种方法:
1)在业务逻辑中添加额外的代码以更新搜索索引。
2)运行一个单独的任务来定期重建索引。

I am trying to utilize Lucene to develop full text search in my application, which need to build index based on my mysql database. I was wondering is how to keep these index synchronized with db? I came up with to ways: 1) add extra code in business logic tightly to update the search index . 2) running a separated task to rebuild the index periodically.

你还有其他方法吗?你认为最好的方法是什么?
如有任何意见,请提前感谢!

do you have any other approaches? and what do you think is the best way? Any comments would be appreciate, thanks in advance!

推荐答案

如果您使用Hibernate,请查看 Hibernate搜索项目。它应该涵盖很多样板。

If you use Hibernate, check out Hibernate search project. It should cover a lot of boilerplate.

这篇关于如何使Lucene索引与Mysql数据库保持同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆