Wednesday, July 31, 2013

Solr - Set Unique Key With UUID

Just like using auto-increment primary keys in a traditional database, sometimes we would like to uniquely identify a document in Solr. In this case, we can use something called UUID. Although it is not a perfect solution, giving the extremely low probability of a duplicated UUID we can reasonably believe that it is safe. Here is how to configure Solr to use UUID:
1. Change the field for id in conf/schema.xml to the following line
2. Add the uuid field type
3. Add the following lines to solrconfig.xml. (We can put it below a comment block started with Update Processors )

    
        id
    
    

4. We can then put a referece to that processor in the handlers that upload a document. Like this:

    
        dedupe
        uuid
    

Tuesday, July 30, 2013

Solr - Debug Solr with Eclipse

This post has great description of how to debug Solr with eclipse.
NOTES:
1. If you want to step through Solr's source code. You may want to comment out cache configurations in solrconfig.xml (solr/collection1/conf/solrconfig.xml). Otherwise, it would step through the code using cache after you first run a query.
2. The entry point for a Solr "select" request is SolrDispatchFilter.doFilter. (org.apache.solr.servlet)

Solr - Merging Indexes

1. Run the command:
java -cp lucene-core-3.4.0.jar:lucene-misc-3.4.0.jar org.apache.lucene.misc.IndexMergeTool ./newindex ./app1/solr/data/index ./app2/solr/data/index
to merge two indexes. (Replace the path with your real path)
2. Put the files in newindex into the index directory of your Solr Home. (solr/collection1/data/index)
For more information, go to Merging Solr Indexes


Solr - Get Started

1. Download the latest Solr release here
2. Extract the package. (The root location will be referred to as [solr-dist] in the rest of the article)
3. Go to [solr-dist]/solr/example and run:
java -jar start.jar
to start Solr
4. Go to [solr-dist]/solr/example/exampledocs and run:
java -jar post.jar *.xml
to index some sample documents into Solr
5. Now you can go to http://localhost:8983/solr/collection1/browse to start searching.
For more information, go to Solr Tutorial