0

Is it possible to change the UniqueKey-tag in schema.xml from String to Int or Long? My Primary key in my application is of type Long - so it's not favorable to get a Solr-response of type string.. So if possible: how can it be done?

Thanks in advance!

Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39

1 Answers1

0

Start by referering the <uniqueKey>-tag in schema.xml/managed-schema to a desired name which describes the key well. Let's call this name "id".

You then need a <field>-tag with the parameter name="id" - so that <uniqueKey> is refering to a defined field. The type of the field is easy to adjust by altering the "type"-parameter - in this case either to float or int.

Resources on defining fields: https://cwiki.apache.org/confluence/display/solr/Defining+Fields

mbjorgan
  • 328
  • 2
  • 12
  • We cannot directly change the Type in schema.xml/managed-schema..if We do then Will get following exception ":org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Error initializing QueryElevationComponent." please refer following link for more Info http://stackoverflow.com/questions/19420972/declaring-unique-key-as-int-in-solr-results-in-error.. Apart from this Any other way or solution to Change the Type of -tag – sachin kumar Jul 11 '16 at 13:51
  • Another approach might be to use a copy field and set the desired type on that field. – arun Jul 05 '18 at 16:15