12

I was browsing some questions here concerning MySQL and faceted searches and I saw one response that suggested the use of Solr.

In my MySQL database, I have many tables for products, suppliers, messages, users, etc - all interconnected. How would I use Solr to do faceted searches for products? From what I understand, I'd have to keep feeding Solr product data from MySQL - but how do I deal with indexing the data? Do index right after adding a new product? Do I batch index? How do I deal with Solr accurately representing data that is found in my MySQL database? (inserts, deletes, etc)

Thanks in advance.

RS71
  • 121
  • 1
  • 3
  • What language and framework is your application built in? There are a lot of good Solr clients out there (e.g. Sunspot for Ruby apps) which can handle this kind of denormalizing and updating pretty transparently. – Nick Zadrozny Jan 05 '11 at 17:34
  • I'm currently using the CodeIgniter framework in PHP. Anything you could suggest me? – RS71 Jan 05 '11 at 19:19

3 Answers3

8

Take a look at data import handler. Apart from batch update you can also trigger update by calling update request handler. You would have to call it from your application but you can also create your own custom update request handler that would fit your needs.

Jarek Rozanski
  • 780
  • 1
  • 6
  • 13
  • How do I deal with deletes? From what I understood the data import handler deals mostly with inserts and updates. Thanks. – RS71 Jan 05 '11 at 19:23
  • Check this for handling deletes in Solr. http://stackoverflow.com/questions/1555610/solr-dih-how-to-handle-deleted-documents – Shashikant Kore Jan 06 '11 at 04:34
  • Add, update and delete is handled by update handler. Action depend on XML message sent. Check this resource: http://wiki.apache.org/solr/UpdateXmlMessages#A.22delete.22_by_ID_and_by_Query. In extreme case you could write store procedure that would be attached to trigger on insert/update/delete on you DB table. However if there is application on top of you DB I would go with baking index maintenance logic into it. – Jarek Rozanski Jan 06 '11 at 22:01
  • Mind you, if you have big indexes which under heavy use you might consider going multi-core. In this scenario, you allow searchin on one core while building/updating second one. Once happy, or in given time intervals, you could swap secondary for main and start building main (for example batch update with data import handler). http://wiki.apache.org/solr/CoreAdmin#SWAP – Jarek Rozanski Jan 06 '11 at 22:05
0

If using data import handler, use the delta import command.

Joyce
  • 1,431
  • 2
  • 18
  • 33
0

SOLR is a JAVA application but you can access it using any language that provides HTTP GET/POST functionality.

for your need you should refer to http://wiki.apache.org/solr/DataImportHandler but before jumping on the Indexing part go through the tutorial at lucene.apache.org /solr /tutorial.html

Umar
  • 2,819
  • 20
  • 17