Indexing Configuration

Each HawkSearch index relies on a JSON configuration file stored as a Salesforce static resource. This configuration file supports indexing standard and custom fields from any queryable object. Below, we'll illustrate examples using standard fields from the Salesforce Product2 object.

The JSON structure consists of two primary keys:

{
  "objects": […],
  "hierarchies": […]
}
KeyValue
objectsThis array includes configurations defining which Salesforce object records are sent to HawkSearch. Typically, each Salesforce object has one corresponding entry, although multiple configurations for the same object are permitted.
hierarchiesHierarchies support nested or hierarchical facets (e.g., product categories). Provide configurations here to build hierarchical facets within HawkSearch.

Object Configuration

A basic Product2 object configuration example indexing the Salesforce ID, Name, DisplayUrl, and ProductCode, along with associated categories:

{ 

    "objectName": "Product2", 
    "condition": "IsActive=true", 
    "fields": [ 
        { 
            "salesforceField": "Id", 
            "HawkSearchField": "id" 
        }, { 
            "salesforceField": "Name", 
            "HawkSearchField": "name" 
        }, { 
            "salesforceField": "DisplayUrl", 
            "HawkSearchField": "url" 
        }, { 
            "salesforceField": "ProductCode", 
            "HawkSearchField": "sku" 
        } 
    ], 

    "children" : [ 
        { 
            "objectName": "ProductCategoryProducts", 
            "condition": "IsDeleted=false", 
            "fields": [ 
                { 
                    "salesforceField": "ProductCategory.Id", 

                    "HawkSearchField": "category_id" 
                }, { 
                    "salesforceField": "ProductCategory.Name", 
                    "HawkSearchField": "category_name" 
                }
            ], 

            "isSeparateQuery": false 
        } 
    ] 
} 

 
KeyValue
objectNameSalesforce API name (not label) of the object to be indexed.
conditionOptional SOQL WHERE filter to limit indexed records

(see SOQL WHERE Syntax)
fieldsA list of field objects (see Field Configuration below)
childrenA list of object configuration objects. Note that for any children, objectName here should be the child relation name, not the object name.

Additionally, object configurations here have the additional flag isSeparateQuery (default false). Salesforce has a limit on the number of records retrieved through child queries. If this limit is hit during indexing, using isSeparateQuery will fetch child records using a separate query instead of a subquery to get around that limit.

Field Configuration

KeyValue
salesforceFieldThe API name of the field in Salesforce to be indexed. This does support parent lookups (e.g., ProductCategory.Id).
HawkSearchFieldThe name of the field in HawkSearch that data should be indexed to. This will be auto created if the “Create Fields and Facets” option is checked in the basic configuration.

Hierarchy Configuration

This is an example of a hierarchy configuration build on the parent/child tree in the standard ProductCategory object.

{ 

    "fieldName": "category_id", 
    "objectName": "ProductCategory", 
    "idField": "Id", 
    "labelField": "Name", 
    "parentField": "ParentCategory.Id", 
    "orderField": "SortOrder", 
    "urlField": "", 
    "imageUrlField": "", 
    "customField": "", 
    "condition": "" 
} 
KeyValue
fieldNameHawkSearch field used for hierarchy creation.
objectNameThe Salesforce API name (not label) of the object to query for the hierarchy information.
idFieldThe Salesforce field to use as a unique identifier for a node in the hierarchy.
labelFieldThe Salesforce field to use as a user-visible label for a node in the hierarchy.
parentFieldThe Salesforce field to use when determining parent/child relationships. This will typically be a Lookup or Master-Detail.
orderFieldAn optional field used to specify the ordering of children, typically a Number field.
urlFieldAn optional field holding the URL for a node in the hierarchy.
imageUrlFieldAn optional field holding an image URL for a node in the hierarchy.
customFieldAn optional field used to hold implementation-specific custom information related to a node in the hierarchy.
conditionA SOQL WHERE clause to determine which object records to include in the hierarchy.