Hawksearch v4.0 - Indexing API

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







Example 2.1

Delete single item from index

{
    "IndexName": "myengine.20200123.153931",

         "Id": "Item_DocId"
}



Response

None or Message with Error

Object

Data Type

Description

Object

Data Type

Description

IndexNames

Array of strings

Each string contains the names of the indexes that exist in the engine.  The most recently created will be listed first.

IndexName

String

Contains the name of the index that is currently active.

Message

String

Will return error message in case if occurs





Example 2.2

{
    "Message": "Unable to retrieve item: 'Item_160373'."
}

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







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



Ids

Array of strings

Yes

Each string contains the document id of an item that suppose to be delete







Example 3.1

Delete single item from index

{
    "IndexName": "myengine.20200123.153931",

         "Ids": ["Item_DocId", "Item_Doc2Id"]
}



Response

None or Message with Error

Object

Data Type

Description

Object

Data Type

Description

None or Message with Error









Example 3.2

{
    "Message": "Unable to retrieve item: 'Item_160373'."

}

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







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 that should be deleted







Example 4.1

Delete index

{
    "IndexName": "myengine.20200123.153931"

}



Response

None or Message with Error



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







Name

Data Type

Required

Description

Source  or  Admin Section

Name

Data Type

Required

Description

Source  or  Admin Section

None











Response

The response returns name of the current index.  This Index Name can then be used as a parameter for other method calls. 

Object

Data Type

Description

Object

Data Type

Description

IndexNames

Array of strings

Each string contains the names of the indexes that exist in the engine.  The most recently created will be listed first.





Example 5.1

{

    "IndexNames": [

        "myengine.20200123.081421",

        "myengine.20200123.074248",

        "myengine.20200123.145534",

        "myengine.20200123.114936",

        "myengine.20200123.114657",

        "myengine.20200123.114151"

    ]

}

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







Name

Data Type

Required

Description

Source or Admin Section

Name

Data Type

Required

Description

Source or Admin Section

None





  





Response

The response returns name of the current index.  This Index Name can then be used as a parameter for other method calls. 

Object

Data Type

Always

Description

Object

Data Type

Always

Description

IndexName

String

Yes

Contains the name of the index that is currently active.





Example 5.1

{
    "IndexName": "myengine.20200123.153932"
}

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







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 to which the item(s) should be added. 

When the index was created, the IndexName was returned in the response from the Create method or the GetCurrentIndex method.



Items

Array of Objects

yes

The Items object will contain all of the attributes that are to be stored for each object. For any object that will be used to supply a facet, the values provided will be the values displayed in the facet on the front-end.

Each item must contain a primary key that matches the primary key defined in the Hawksearch Workbench.

Missing primary key property or passing value that doesn't match the Hawksearch Workbench settings will cause returning error for Item in a Response. The response will return the item in with Status: "Failed" and following error message: "'Primary Key' doesn't exist in the field definition."

Missing correct fields configuration in the Hawksearch Workbench will also cause returning an error for an Item. The response will return the item in with Status: "Failed" and following error message: "There is no fields definition. After adding fields configuration"

















Example 6.1

{

       "IndexName": "demo.20200221.090452",

       "Items": [

       {

              "id": ["123"],

              "Sku": ["987654"],

              "title": ["Rain Jacket"],

              "price": ["39.99"],

              "saleprice": ["32.99"], "image":["https://www.mysite.com/images/Thumbnail/987654.jpg"],

              "url_detail":["https://www.mysite.com/jackets/mens/987654"],

              "brand" : ["Acme"],

              "color" : ["Orange"]

       },

       {

              "idx": ["987"],

              "Sku": ["123456"],

              "title": ["Down Jacket"],

              "price": ["89.99"],

              "saleprice": ["74.99"], "image":["https://www.mysite.com/images/Thumbnail/123456.jpg"],

              "url_detail":["https://www.mysite.com/jackets/mens/123456"],

              "brand" : ["Acme"],

              "color" : ["Black"]

       }]

}