Imagine you have an application that crawls the web and index documents found during that crawl. The problem is that for some particular reason you can't set the document identifier during indexing, and you would like Solr to generate one for you. This recipe will help you, if you faced a similar problem.
The following steps will help you to generate unique fields automatically:
First let's create our index structure by adding the following entries to the
schema.xmlfields
section:<field name="id" type="uuid" indexed="true" stored="true" default="NEW" multiValued="false"/> <field name="name" type="text_general" indexed="true" stored="true"/> <field name="text" type="text_general" indexed="true" stored="true"/>
In addition to that, we need to define the
uuid
field type by adding the following entry to thetypes
section of ourschema.xml
file:<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
In addition...