Hawksearch v4.0 - Indexing API

Important

Depending on the version of HawkSearch used, method of integration, and the presence of data feed files for indexing, you may need to perform indexing as per this article or Using Dashboard API to Rebuild Indexes. Please contact HawkSearch for any clarifications.

Contents

Domains

Hawksearch has three environments available: Development, Test and a load-balanced Production.  When using the search API methods in this document, the following domains can be used to access each environment after your engine has been set-up in that environment.

Development

https://indexing-dev.hawksearch.net/

Configurations for an engine in this location are maintained in the Hawksearch Workbench at dev.hawksearch.net.

Test

https://indexing-test.hawksearch.net/

Configurations for an engine in this location are maintained in the Hawksearch Workbench at test.hawksearch.net.

Production

https://indexingapi-na.hawksearch.com/

Configurations for an engine in this location are maintained in the Hawksearch Workbench at https://dashboard-na.hawksearch.com/



Indexing API Methods

Create

This method creates a new index in Hawksearch.  The new index will be empty.  Other methods must be used to populate the index. The methods, IndexItems and DeleteIndexItems are used to add, update and delete items in an index.  The index will not be set to be active until the Set-Current method is called, passing the name of the index.  Each client engine can have multiple indexes, but only 1 current index at a time.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/create

POST

X-HawkSearch-ApiKey







Name

Data Type

Required

Description

Source or Admin Section

Name

Data Type

Required

Description

Source or Admin Section

Suffix

String

no

Optional suffix that will be applied to the name of the index to be created.  This may be useful to track the purpose of creating this specific index (i.e. testing a new field).  The string should have no spaces in it.  







Example 1.1

Creating index with a suffix

{
    "Suffix": "test-addingcolorfamily"
}



Response



Object

Data Type

Always

Description

Object

Data Type

Always

Description

IndexName

String

Yes

Contains the name of the newly created index.  If the Suffix parameter was populated in the request, it will be the value after the last period.





Example 1.2

With a suffix

{
    "IndexName": "myengine.20200123.153931.test-addingcolorfamily"
}

Example 1.3

Without a suffix

{
    "IndexName": "myengine.20200123.153932"
}

Delete Index Item

This method delete the single item from existing index in Hawksearch.  

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/delete

POST

X-HawkSearch-ApiKey







Name

Data Type

Required

Description

Source or Admin Section

Name

Data Type

Required

Description

Source or Admin Section

IndexName

String

Yes

The name of the index from which item should be deleted



Id

String

Yes

The document id of corresponding item that suppose to be delete







Response



Delete Index Items

This method deletes multiple items from existing index in Hawksearch.  

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/delete-items

POST

X-HawkSearch-ApiKey







Response



Delete Index

This method delete an existing index in Hawksearch.  

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/delete-index

POST

X-HawkSearch-ApiKey







Response



Get All Indexes

This method will return all of the indexes that exist for the engine.  

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/

GET

X-HawkSearch-ApiKey





Response



Get Current Index Name

This method will return the name of the index that is currently being used for search. If there is no “current index,” an error will be returned.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/current

GET

X-HawkSearch-ApiKey





Response



Index Items

This method adds and updates items and their attributes to a specified index. Attributes must be defined in the Hawksearch Workbench Fields list in order for the attributes to be stored for an object. Once an item is indexed with this method, it will immediately be available in search results, if the modified index is queried.

If an item is sent with a key that matches an existing item, that item will be updated with the attributes being sent. If an item is sent with a new key, that item will be added to the index.

Note: To index hierarchical data, please build the hierarchy using the Hierarchy API and then call the index-items API.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/index-items

POST

X-HawkSearch-ApiKey







Response

Update Items

This method updates items and their attributes to a specified index. Attributes must be defined in the Hawksearch Workbench Fields list in order for the attributes to be stored for an object. Once an item is updated with this method, it will immediately be available in search results, if the modified index is queried.

If an item is sent with a key that matches an existing item, that item will be updated with the attributes being sent. If an item is sent with a new key, that item will be added to the index. The item will be updated with the attributes being sent. Note that in this method, you can send only those attributes in the request which are required to be updated along with the Primary key and skip the ones which do not require any changes

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/update-items

POST

X-HawkSearch-ApiKey







Response

Set Current Index

Sets a specified index as the current index.  This will be the index that will be used when calling Hawksearch search methods (documented in a separate document).

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/set-current

POST

X-HawkSearch-ApiKey





Response

Rebuild All

Rebuilds autocomplete, percolator, learning search and related searches.  

Note

Please note that rebuild-all API does not rebuild the complete index. This is not to be mistaken with full index rebuild process.

Rebuild All only rebuilds the four secondary indices but not the primary index which has the items data. Hence, please follow the steps under FAQ section down below to perform a full index rebuild.



Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/rebuild-all

POST

X-HawkSearch-ApiKey





Response



Rebuild Autocomplete

Rebuilds Autocomplete Categories & Autocomplete Popular Items.  This method is called as part of Rebuild-All.  It is not required that this method be called separately.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/rebuild-autocomplete

POST

X-HawkSearch-ApiKey





Response



Rebuild Percolator

Rebuilds Percolator (boost rules & visitor target rules) for Hawksearch.  This method is called as part of Rebuild-All.  It is not required that this method be called separately.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/rebuild-percolator

POST

X-HawkSearch-ApiKey





Response



Rebuild Learning Search

Rebuilds Learning Search & Learning Search By Visitor.  This method is called as part of Rebuild-All.  It is not required that this method be called separately.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/rebuild-learning

POST

X-HawkSearch-ApiKey





Response



Rebuild Related

Rebuilds Related Searches.  This method is called as part of Rebuild-All.  It is not required that this method be called separately.

Request

Endpoint

Method

Header Key

Endpoint

Method

Header Key

api/v2/indexing/rebuild-related

POST

X-HawkSearch-ApiKey





Response

FAQs

Hawksearch v4.0 - Indexing API - What are the basic steps to getting an index up?

Create Fields

  1. Establish what fields/attributes need to be in Hawksearch. Consider what needs to be searched, what needs to be displayed on the search results page and what might be needed to use for merchandising. Some examples of fields that could be needed for merchandising: a rating field to sort by top rated; a sales margin to use for featured products.

  2. Create fields in Hawksearch workbench for each field/attribute that will be sent to Hawksearch. Alternatively, these fields can be created using the REST API.

(Optional) Create Facets

  1. Once the fields are created in Hawksearch, Facets can then be created. This step is optional in the sense that it is not required to be done at this time, and can be completed after the data has been initially indexed, but Facets should be created at some point to make for a richer search results page, that is also easier to navigate. 

  2. Consider the expectations of your users and what navigation choices they would expect to have available, and consider what fields of data are available for facet use. 

  3. Facets can be created from the Hawksearch workbench, or through the REST API. 

(Optional) Remove old index

  1. If applicable, delete inactive index using the delete API call

Create Index

  1. Use the 'Create' call documented above to create the empty index. 

  2. NOTE: You are limited to a total of two indexes. If you already have two indexes created, you will need to first delete one before you can create a new index. Please see the 'Delete' call documented above for instructions on how to perform this action. 

(Optional) Build Hierarchy

  1. Use the upsert call to add/update new hierarchies (ref Hierarchy API) to add your hierarchical data for nested facets.

  2. Build the hierarchical data model using the build call.

Index Items

  1. Use the Index-Items call to import data into the Index.

(Optional) Set Current Index

  1. You can choose to set the current index using the relevant call, but it is not required. You can submit the index you would like to search against as part of the search call. However, if you do set the current index - that information does not need to be included in the search call. 

Rebuild All

  1. This final step rebuilds several Hawksearch functions - the autocomplete, percolator, learning search and related searches. 

Method Calls Overview

  1. Delete (for older index)

  2. Create (the new index)

  3. Upsert and Rebuild (the hierarchy)

  4. Index-Items (your products)

  5. Set-Current (the latest index)

  6. Rebuild-All (on the latest index)



More info - Full v/s Partial Indexing - Hawksearch Knowledge Base - Confluence (atlassian.net)

Why do I have to send the index name in every request if I am sending the key?

You will have the flexibility to have multiple indexes stored in Hawksearch. The index name is required to indicate on which index the action should be taken.