I was asked today if it makes sense to change the name of the default id field in Solr to something else?
Let me explain. You download your Solr, you get it up and running and you start modifying fields in Schema.xml. Currently the uniquekey is called id and it is defined as uniquekey. No harm done in leaving as is. It looks something like what I have below.
<field name=”id” type=”string” indexed=”true” stored=”true” required=”true” multiValued=”false” />
At first it may seem like it doesn’t matter what it is actually called, however if you think about it a little bit more it may make sense to change it.
Simple. Because id, by being the default value may be used in other locations, even in sample code and it may have been used for specific purposes or in ways that you are not aware of.
So by changing it, you are forcing yourself to be aware of where the id field is being used. It is not a huge difference, but the devil is in the details.
Something as easy as changing it to look like this is more than enough.
<field name=”itemid” type=”string” indexed=”true” stored=”true” required=”true” multiValued=”false” />
Want a more precise example? Run SolrNet’s sample app and just change the name of the uniquekey. Tell me how it went!