The FieldType API allows creating, updating and deleting field types that are used by LucidWorks Search to define how text found in a field should be processed during indexing. For example, dates should be processed differently from prices as they are generally structured differently in documents. The "date" field would use a field type appropriate for dates, while the "price" field would use a field type appropriate for prices. Many field types are included with LucidWorks and in some cases new ones do not need to be created. However, if the existing list of field types is insufficient for your implementation, this API will allow you to create new field types without manually editing the schema.xml configuration file. Alternately, however, the LucidWorks Admin UI includes a Field Types screen to create, update and delete field types.
| Field Types Require Advanced Knowledge of Solr's Schema LucidWorks uses Solr's schema.xml to define field types and fields, and all the functionality contained in Solr is available within LucidWorks Search. That said, FieldType configuration is for advanced users. This API is intended for those who prefer not to edit the schema.xml file by hand but who would be entirely comfortable doing so if required. |
| About Field Type Properties There are only two properties common to all field types: "class" and "name". Other properties will vary according to the class. Some may have a map of analyzers which may include char_filters, tokenizers, and/or token_filters. Property names (for the class, name, analyzers, etc.) are all strings, even if they are numeric or boolean. They follow the naming convention found in schema.xml, which is to say that while most of the properties in LucidWorks Search follow a "under_score" naming convention, field type properties will generally be in "camelCase", meaning that the property names are identical to the attribute names as specified in a valid Solr schema.xml file. |
API Entry Points
/api/collections/collection/fieldtypes: get a list of all field types
/api/collections/collection/fieldtypes/fieldtype: create, update, delete, or get details for a specific field type
Get a List of All Field Types
GET /api/collections/collection/fieldtypes
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection where this field type is available |
Query Parameters
None
Output
Output Content
A JSON List of Maps mapping FieldType keys to values. There are only two properties that are common to all FieldTypes; the other properties vary by the class of the field type. All of the classes available in Solr are also available in LucidWorks.
| Key | Type | Description |
|---|---|---|
| class | string | The implementing class for this field type |
| name | string | The name of the field type |
Response Codes
200: OK
Examples
Input
curl 'http://localhost:8888/api/collections/collection1/fieldtypes'
Output
The example below has been truncated for space (indicated by "..." at the beginning and end of the example - the full output would be much longer).
...
{
"class":"solr.DateField",
"name":"pdate",
"omitNorms":"true",
"sortMissingLast":"true"
},
{
"class":"solr.TextField",
"name":"text_ws",
"positionIncrementGap":"100",
"analyzers":{
"default":{
"char_filters":[],
"tokenizer":{
"class":"solr.WhitespaceTokenizerFactory"
},
"token_filters":[]
}
}
}
...
Get Details for a Specific Field Type
GET /api/collections/collection/fieldtypes/fieldtype
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection where this field type is available |
| fieldtype | The name of the field type |
Query Parameters
None.
Output
Output Content
A JSON List of Maps mapping Collection keys to values. There are only two properties that are common to all FieldTypes; the other properties vary by the class of the field type.
| Key | Type | Description |
|---|---|---|
| class | string | The implementing class for this field type |
| name | string | The name of the field type |
Response Codes
List valid response codes and meaning
Examples
Input
curl 'http://localhost:8888/api/collections/collection1/fieldtypes/text_en
Output
{
"analyzers" : {
"index" : {
"token_filters" : [
{
"splitOnCaseChange" : "1",
"catenateWords" : "1",
"catenateAll" : "0",
"generateNumberParts" : "1",
"class" : "solr.WordDelimiterFilterFactory",
"catenateNumbers" : "1",
"generateWordParts" : "1"
},
{
"class" : "solr.LowerCaseFilterFactory"
},
{
"class" : "solr.ASCIIFoldingFilterFactory"
},
{
"class" : "com.lucid.analysis.LucidPluralStemFilterFactory",
"rules" : "LucidStemRules_en.txt"
}
],
"char_filters" : [],
"tokenizer" : {
"class" : "solr.WhitespaceTokenizerFactory"
}
},
"query" : {
"token_filters" : [
{
"ignoreCase" : "true",
"synonyms" : "synonyms.txt",
"expand" : "true",
"class" : "solr.SynonymFilterFactory"
},
{
"ignoreCase" : "true",
"class" : "solr.StopFilterFactory",
"words" : "stopwords.txt"
},
{
"splitOnCaseChange" : "1",
"catenateWords" : "0",
"catenateAll" : "0",
"generateNumberParts" : "1",
"class" : "solr.WordDelimiterFilterFactory",
"catenateNumbers" : "0",
"generateWordParts" : "1"
},
{
"class" : "solr.LowerCaseFilterFactory"
},
{
"class" : "solr.ASCIIFoldingFilterFactory"
},
{
"class" : "com.lucid.analysis.LucidPluralStemFilterFactory",
"rules" : "LucidStemRules_en.txt"
}
],
"char_filters" : [],
"tokenizer" : {
"class" : "solr.WhitespaceTokenizerFactory"
}
}
},
"positionIncrementGap" : "100",
"name" : "text_en",
"class" : "solr.TextField"
}
Create a Field Type
POST /api/collections/collection/fieldtypes
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection where this field type will be available |
Query Parameters
None.
Input Content
See the note about properties at the top of the page.
Output
Output Content
A JSON List of Maps mapping Collection keys to values.
| Key | Type | Description |
|---|---|---|
| class | string | The implementing class for this field type |
| name | string | The name of this field type |
Other properties will also be listed if set during creation.
Response Codes
422: FieldType structure was not syntactically correct
Examples
Input
Simple Example
curl -H 'Content-type: application/json' -d
'{
"class":"solr.TextField",
"name":"newfieldtype"
}' 'http://localhost:8888/api/collections/collection1/fieldtypes'
Example with Analyzers
curl -H 'Content-type: application/json' -d
{
"name" : "test_field",
"class" : "solr.TextField",
"analyzers" : {
"default" : {
"token_filters" : [],
"char_filters" : [],
"tokenizer" : {
"class" : "solr.WhitespaceTokenizerFactory"
}
}
},
"positionIncrementGap" : "100"
}' 'http://localhost:8888/api/collections/collection1/fieldtypes'
Output
Simple Example
{
"class":"solr.TextField",
"name":"newfieldtype"
}
Example with Analyzers
{
"class":"solr.TextField",
"name":"test_field",
"positionIncrementGap":"100",
"analyzers":{
"default":{
"char_filters":[],
"tokenizer":{
"class":"solr.WhitespaceTokenizerFactory"
},
"token_filters":[]
}
}
}
Update Details for a Specific Field Type
PUT /api/collections/collection/fieldtypes/fieldtype
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection name |
| fieldtype | The field type name |
Query Parameters
None.
Input Content
See the note about properties at the top of the page.
Properties can be removed from an existing field type by specifying a null value in the PUT request. The analyzers attribute is considered an individual attribute, so any changes to any part of the sections within the analyzers attribute require sending the entire analyzers attribute.
Output
Output Content
None.
Response Codes
200: OK
422: Unprocessable Entity
405: Method Not Allowed
Examples
Input
curl -X PUT -H 'Content-type: application/json' -d
'{"positionIncrementGap":"50"}'
'http://localhost:8888/api/collections/collection1/fieldtypes/text_en'
Delete a Specific Field Type
DELETE /api/collections/collection/fieldtypes/fieldtype
Input
Path Parameters
Enter path parameters.
| Key | Description |
|---|---|
| collection | The collection where this field type is available |
| fieldtype | The fieldtype name |
Query Parameters
None.
Output
Output Content
None.
Response Codes
200: OK
Examples
Input
curl -X DELETE -H 'Content-type: application/json'
'http://localhost:8888/api/collections/collection1/fieldtypes/payloads'