自动将数据从mysql导入到solr
我想将值从 mysql 导入到 solr..我通过
使用 mysql 触发器调用 php 脚本来进行自动导入。但我读到这不是一个好方法..还有其他
自动导入数据的解决方案吗?
有人可以帮我吗lz...
I want to import values from mysql to solr.. I did automatic import by calling a php script
using mysql trigger. But i read that its not a good method.. Is there any other solution for
importing data automatically?
Can someone help me plzz...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尽管正如其他响应中提到的那样,有一个内置的机制,
数据导入处理程序 (DIH)
,但我发现这个工具不是很灵活。我的意思是,如果我想在索引之前进行任何数据处理,我只能依赖 MySQL 函数,而我可以使用 PHP 函数。我最终将自己的数据导入处理程序编写为 PHP 脚本,在其中执行初始查询,然后逐步执行结果并在插入 SOLR 索引时处理(和缓存)数据。它并不太复杂,看起来像这样(仅是演示性的):
这只是您可以执行的操作的一个示例,在我的情况下,当我进行完全导入时,我还涉及缓存以提高性能。使用本机 DIH 无法做到的事情。
我用来通过PHP访问SOLR的API是solr-php-client,可能还有其他的在那里,所以谷歌周围。
Even though there is a built in mechanism for this very thing,
Data Import Handler (DIH)
, as mentioned in the other responses, I found this tool not very flexible. What I mean by this is, if I wanted to do any data massaging before indexing I could only depend on MySQL functions, when I could have used PHP functions.I ended up writing my own Data Import Handler as a PHP script, where it does the initial query, then steps through the results and massages (and caches) data upon insert into the SOLR index. It wasn't too complicated, and would look something like (demonstrative only):
This is just an example of what you can do, In my situation I also involve caching to increase performance when I do a full import. Something you cannot do using the native DIH.
The API I use to access SOLR through PHP is solr-php-client, there may be others out there, so google around.
Solr DataImportHandler 将帮助您从 mysql 导入数据并对其建立索引。
它提供了完整索引以及增量索引数据。
但是,它不会是自动的,您需要通过调度程序 cron 来触发数据导入。
正在研究一些用于调度的选项。
Solr DataImportHandler would help you the import from the data from mysql and get it indexed.
It provides ability to Full index and well as Incrementally index the data.
However, it would not be automatic and you need to fire the data imports through a scheduler, cron.
There are some options being worked upon for Scheduling it.
您还可以使用 Solr 数据导入处理程序
You could also use the Solr Data Import Handler