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
    

No comments:

Post a Comment