我最近开始使用 MongoDB 和 Apache Solr。我使用 MongoDB 作为数据存储,并且希望 Apache Solr 为我的数据创建索引,以实现应用程序中的搜索功能。
经过一些研究,我发现,基本上有两种方法可以在 MongoDB 和 Solr 之间同步数据。
1)使用 Solr DataImportHandler -
为此,我使用了 james 创建的 SolrMongoImporter 并遵循了他的教程github https://github.com/james75/SolrMongoImporter
我能够成功运行导入处理程序,并且 Solr 识别了导入处理程序,但它没有将任何文档导入到 solr 中。每次都说更新文档=0。
2)然后我尝试切换到MongoDB端,看看那里是否存在任何东西,我发现MongoDB连接器 https://github.com/10gen-labs/mongo-connector由 10gen 提供。
当我按照说明操作并运行连接器时,它尝试将大量文档发布到 Solr 并给出以下输出。
2012-11-24 15:15:20,665 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.010 seconds.
2012-11-24 15:15:21,674 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.009 seconds.
2012-11-24 15:15:22,683 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.008 seconds.
2012-11-24 15:15:23,694 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.010 seconds.
2012-11-24 15:15:24,702 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.008 seconds.
2012-11-24 15:15:25,711 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.008 seconds.
2012-11-24 15:15:26,722 - INFO - Finished 'http://localhost:8983/solr/update/?commit=true' (POST) with body '<commit />' in 0.010 seconds.
但 Solr 中没有数据。
我想知道哪种方法适合你们,以及是否有关于 MongoDB 和 Solr 集成的好的教程。
另外,我正在寻找 MongoDB 和 solr 之间的实时同步,即只要将任何产品添加到我的 mongodb,我希望它在 solr 索引中更新并反映在搜索结果中。
我正在使用 MongoDB 2.0.4 和 Solr 3.6.1。