Tuesday, June 21, 2011

Solr Search - Some Tips And Pointers

We've recently launched a huge project where we implemented Solr as the search platform. Even though Solr is quite easy to get started with, we've got a few tips and pointers to make life with Solr easier for you!

Know your configuration files

We had some initial trouble with the Solr configuration files, normally located under C:/solr/conf. The most important configuration files are solrconfig.xml and schema.xml.

  • In schema.xml, make sure the fields matches those you've defined in your application.
  • The config files are case sensitive! Make sure you spell copyField, multiValued etc correctly.
  • If you don't need elevation and have problems with configuration, try turning off the elevate.xml handler by uncommenting the appropriate lines in solrconfig.xml.

Improve performance by customizing solrconfig.xml

Solrconfig.xml holds a lot of fun stuff. Here you can setup Solr to improve the performance. If your hardware is up for it, that is.

Here are a few elements to get your started:

  • mergeFactor decides what size your index segments should have, thus either improving indexing or searching.
  • ramBufferSizeMB sets the amount of RAM available for Solr, before documents are flushed.
  • autoWarmCount may be used to pre-populate data from the search index.

Here's a great wiki page on Solr and performance, for further reading and available configuration options.

Use an absolutely unique key

You should define a unique key that will always be unique for a specific item in your Solr index. Either you assign this unique key an auto generated GUID, or you use Solr's built in UniqueKey field.

In schema.config, add the Solr UUID type:

<fieldType name="uuid" class="solr.UUIDField" indexed="true" />

Also add a field of the UUID type:

<field name="uid" type="uuid" indexed="true" stored="true"
default="NEW" />

Finally, point out the field as the unique key:



This was just some quick tips and pointers to get you more comfortable with Solr. More specifics on the project launch to come!

No comments :

Post a Comment