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": […]
}
Key | Value |
---|---|
objects | This 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. |
hierarchies | Hierarchies 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
}
]
}
Key | Value |
---|---|
objectName | Salesforce API name (not label) of the object to be indexed. |
condition | Optional SOQL WHERE filter to limit indexed records (see SOQL WHERE Syntax) |
fields | A list of field objects (see Field Configuration below) |
children | A 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
Key | Value |
---|---|
salesforceField | The API name of the field in Salesforce to be indexed. This does support parent lookups (e.g., ProductCategory.Id ). |
HawkSearchField | The 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": ""
}
Key | Value |
---|---|
fieldName | HawkSearch field used for hierarchy creation. |
objectName | The Salesforce API name (not label) of the object to query for the hierarchy information. |
idField | The Salesforce field to use as a unique identifier for a node in the hierarchy. |
labelField | The Salesforce field to use as a user-visible label for a node in the hierarchy. |
parentField | The Salesforce field to use when determining parent/child relationships. This will typically be a Lookup or Master-Detail. |
orderField | An optional field used to specify the ordering of children, typically a Number field. |
urlField | An optional field holding the URL for a node in the hierarchy. |
imageUrlField | An optional field holding an image URL for a node in the hierarchy. |
customField | An optional field used to hold implementation-specific custom information related to a node in the hierarchy. |
condition | A SOQL WHERE clause to determine which object records to include in the hierarchy. |
Updated 12 days ago