Batch Add or Update Items

search suggestions
curl -X PUT -H "Content-Type: application/json" \
-d '{"items": [ {"item_name": "Golden Retriever"}, {"item_name": "Poodle"} ],
"section":"Search Suggestions"}' \
-u"[your token]:" "https://ac.cnstrc.com/v1/batch_items?force=1&key=[your API key]"
products
curl -X PUT -H "Content-Type: application/json" \
-d '{
"section":"Products",
"items": [
{
"item_name": "Labradoodle",
"suggested_score": 360,
"keywords": ["poodle","labrador","retriever"],
"url": "http://www.mydogs.com/labradoodle",
"image_url": "https://images.mydogs.com/labradoodle.jpg",
"description": "A crossbreed dog created by crossing the Labrador Retriever and the Poodle",
"metadata": { "animal": "dog" },
"group_ids": [ "23", "45" ]
},
{
"item_name": "Australian Shepherd",
"suggested_score": 130,
"keywords": ["aussie"],
"url": "http://www.mydogs.com/australian_shepherd",
"image_url": "https://images.mydogs.com/australian_shepherd.jpg",
"description": "A medium-sized breed of dog developed on ranches in the Western United States",
"metadata": { "animal": "dog" },
"group_ids": [ "67", "89" ]
}
]
}' \
-u"[your token]:" "https://ac.cnstrc.com/v1/batch_items?force=1&key=[your API key]"
info

The above command(s) return a 204 Success response on success.

A batch add or update allows you to add a group of items to your index without first checking to make sure no item in the batch already exists.

Any items that don't already exist are created, and any items that already exist are updated. This is also known as an UPSERT operation.

To add or update a batch of items to your index, use the PUT /batch_items call, with ?force=1. Options are the same as for the standard Batch Add Items call: item_name and section are required and all other parameters are optional.

We determine whether items already exist based on the item_name and section set for each item. However, if the optional id parameter is set for the items, we determine whether items already exist using this parameter.

There is a limit of 1,000 items per batch request.

HTTP Request#

PUT https://ac.cnstrc.com/v1/batch_items?force=1&key=[your API key]

JSON Parameters#

ParameterRequired?Description
sectionYesYour autosuggest and search reuslts can have multiple sections like "Products" and "Search Suggestions". This indicates which section this item is for. See your dashboard for the section names to use.
itemsYesA list of items with the same attributes as defined in the Add an Item resource