/
Field Configuration: Naming Convention

Field Configuration: Naming Convention

Depending on your Hawksearch version and implementation mechanism, this may or may not be applicable to your engine. Please check with your Hawksearch representative for details.

This article explains the naming convention for the “name” attribute of the field and not the “Label”.

Following is the standard convention to note while creating new fields in Hawksearch:

  1. Only alphanumeric characters and the underscore are allowed in the fieldname

  2. All characters are lowercase

  3. Spaces must be replaced by underscores '_'

  4. Underscore cannot be at the beginning or end of the name

  5. Atleast one character is required

  6. Atleast one number is required - an “n” will be appended to it


C# code block for your reference as below:

public static string GetStandardFieldName(string InputField) { var rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9_]"); string SField = InputField; SField = SField.Replace(" ", "_"); SField = rgx.Replace(SField, ""); if (!string.IsNullOrEmpty(SField)) { SField = SField.ToLower(); if (SField.StartsWith("_")) SField = SField.Remove(0, 1); if (SField.EndsWith("_")) SField = SField.Remove(SField.Length - 1); } if (!string.IsNullOrEmpty(SField)) { if(int.TryParse(SField.Substring(0, 1), out int result)) SField= "n" + SField; } return SField; }


Examples:

GetStandardFieldName("Hello, world!") GetStandardFieldName("99Hello, world!") GetStandardFieldName("_1Hello, world!_")

Outputs:

hello_world
n99hello_world
n1hello_world

Live tester - HawkSearch field naming convention, C# - rextester

Related content

Field Assignments
Field Assignments
More like this
Field Configuration: Best Practices - Field Types
Field Configuration: Best Practices - Field Types
Read with this
Field-Specific Search - V2
Field-Specific Search - V2
More like this
Using Boost Values in Fields
Using Boost Values in Fields
Read with this
Hawksearch Field Setup
Hawksearch Field Setup
More like this
Field Configuration: Best Practices - Analyzers
Field Configuration: Best Practices - Analyzers
Read with this