This document helps to cover some basic questions when we try to add a new field via API.
REST URL: https://dev.hawksearch.net/api/v9/Field
Method: POST
Authentication: Basic (Engine API Key)
When creating a new field, you need to make sure that the following attributes are always sent in the request payload otherwise the request would be invalid.
Code Block { "Name": "age", "FieldType": "keyword", "Label": "Age", "Boost": 1, "IsPrimaryKey": false, "IsOutput": false, "IsShingle": false, "IsBestFragment": false, "IsDictionary": false, "IsSort": false, "IsPrefix": false, "IsHidden": false, "IsCompare": false, "IsKeywordText": false, "IsQuery": false, "IsQueryText": false, "SkipCustom": false, "StripHtml": false }
...
2. Please make sure that the field ‘Name’ is unique and a field with the same name does not exist already. You can first get a list of all fields using ‘/api/v9/FieldInfo’ or get this particular field information using field name 'api/v9/Field?fieldName={fieldName}' before creating a new field
...
...
facet
keyword
unindexed
text
Please read more about it here: Best Practices for Field Configuration
4. Multiple fields can have the same ‘Label’ value as long as the Name is unique.
5. Boost has to be set to 1 when IsQuery=false
...
6. IsPrimaryKey should be always set to ‘false’ unless you want to mark that field as a Primary Key. Note that only one field can be a Primary key and it is suggested to NOT change it often as it might have a negative impact on site functionality. Please contact Hawksearch if you would like to change the Primary key.
7. IsOutput should be set to ‘true’ only if you need the field value in the search response. Please always set it to ‘false’ if not in use.
8. IsShingle corresponds to Add phrases to "Did you Mean"? under the field settings on the dashboard.
It has to be set to false when IsQuery=false.
If IsQuery=true, then IsShingle can be set to true only for "Type": "string". You can not use it for types ‘Numeric’ or ‘Boolean’.
If IsQuery=true, then IsShingle can be set to true only for "FieldType": "facet", “keyword” and ”keywordtext”. You can not use it for field types ‘unindexed’, ‘text’.
{keywordtext, "Field values indexed ""as is"" AND are stemmed"},
{keyword, "Field values are NOT stemmed"},
{text, "Field values are ONLY stemmed (search only)"},
{unindexed, "Stored only, not used for search nor facets"},
{facet, "Field values are NOT stemmed"}} >> The field type value changes to ‘facet’ from ‘keyword’ if you set up this field as a facet. For fields that will be used as facet, please set up field type as ‘facet’.
9. Iterations can be skipped from the request but if IsQuery=true, IsShingle = true then we need to set the Iterations value by default to 1.
...
10. Type is the datatype of the field. One of the 3 possible values is String, Single, Boolean. If you set a field as IsQuery=true and IsShingle = true then you need to always pass the Type information in the request as IsShingle cannot be used for types ‘Numeric’ or ‘Boolean’.
11. SortOrder field is optional and can be passed if you would like to maintain a specifc order for all the field values. The value should always be numeric.
...