Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to index data in solr from database automatically

I have MySql database for my application. i implemented solr search and used dataimporthandler(DIH)to index data from database into solr. my question is: is there any way that if database gets updated then my solr indexes automatically gets update for new data added in the database. . It means i need not to run index process manually every time data base tables changes.If yes then please tell me how can i achieve this.

like image 452
Romi Avatar asked Jun 24 '11 05:06

Romi


People also ask

How do I run Solr indexing?

Start the Server If you didn't start Solr after installing it, you can start it by running bin/solr from the Solr directory. If you are running Windows, you can start Solr by running bin\solr. cmd instead. This will start Solr in the background, listening on port 8983.

How does Solr index data?

By adding content to an index, we make it searchable by Solr. A Solr index can accept data from many different sources, including XML files, comma-separated value (CSV) files, data extracted from tables in a database, and files in common file formats such as Microsoft Word or PDF.

How can I make Solr index faster?

Tip #6: commit at the end The auto-commit settings, shown below, can be configured in the solrconfig. xml file. If you configure your index to commit at the end of the indexing process, the auto-commit can efficiently perform commits during the indexing process and limit the performance impact on your indexing process.

What are the correct ways of updating Solr index?

When you index a document to solr, it will overwrite any existing document with the same <uniqueKey/> which is usually the id. So yes, it overwrites existing data. When you want to change a single field of a document you will have to reindex the whole document, as solr does not support updating of a field only.


1 Answers

I don't think there is a possibility in Solr which lets you index the data when any updates happens to DB.

But there could be possibilities like, with the help of Triggers - there is a possibility to run an external application from triggers.

Write a CRON to trigger PHP script which does reading from the DB and indexing it in Solr. Write a trigger (which calls this script) for CRUD operation and dump it into DB, so, whenever something happens to DB, this trigger will call the above script and indexing could happen.

Please see:

Invoking a PHP script from a MySQL trigger

Automatic Scheduling:

Please see this post How can I Schedule data imports in Solr for more information on scheduling. The second answer, explains how to import using Cron.

like image 115
Rakesh Sankar Avatar answered Nov 02 '22 02:11

Rakesh Sankar