Understanding enum fields

Just as Java has the enum data type to have something for a closed set of values, Solr has EnumFieldType, which lets us define closed set values. Here, the sort order is predetermined.

Defining an EnumFieldType is done as follows:

<fieldType name="genreList" class="solr.EnumFieldType" docValues="true" enumsConfig= "enumsConfig.xml" enumName="genre"/>

Here, as you can see, we have defined the name as genreList and the class is specified as solr.EnumFieldType. We also have specified enumConfig to specify the path of the configuration file.

Last but not least, we have specified enumName to uniquely identify the name of the enumeration:

<?xml version="1.0" ?>
<enumsConfig>
<enum name="genre">
<value>Science Fiction</value>
<value>Satire</value>
<value>Drama</value>
<value>Action</value>
<value>Adventure</value>
<value>Mystery</value>
<value>Horror</value>
</enum>
</enumsConfig>

The enumsConfig file can contain many enumeration value lists with different names as per your requirement. Take a look at the content of the enumeration file for the genres shown in the preceding code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.18.4