I need to create a schema which will containt few enums. I\'m trying to do that using SolrJ. I\'ve found this link DefininganEnumFieldinschema but I couldn\'t find any examples
First you need to specify your enum field in schema, like in the documentation:
<fieldType name="myEnumField" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="attribute"/>
in the enumsConfig.xml you will specify all your enum values, like:
<?xml version="1.0" ?>
<enumsConfig>
<enum name="attribute">
<value>sponsored</value>
<value>generic</value>
</enum>
</enumsConfig>
Alternatively, you could create this fieldType dynamically via Schema API as follows:
curl -X POST -H 'Content-type:application/json' --data-binary '{
"add-field-type" : {
"name":"myEnumField",
"class":"solr.EnumField",
"enumsConfig":"enumsConfig.xml",
"enumName" : "attribute"}
}' http://localhost:8983/solr/demo/schema
You could do this as well in SolrJ fashion, by using org.apache.solr.client.solrj.request.schema.SchemaRequest.AddFieldType
, you need to specify FieldTypeDefinition, method setAttributes(Map<String,Object> attributes)
will be helpful