Getting Started with the Indexing API
This guide explains how to manage documents in your AddSearch index using the Indexing API. You will learn to add a document, retrieve its content, and remove a document.
Prerequisites
You need your site's public key and secret API key. Find them in the Keys and installation section of your AddSearch dashboard. Replace {your index public key} and {your index secret key} in the examples with your actual keys.
Each document in the index has a unique ID, used at the end of the API request URL, for example:
https://api.addsearch.com/v2/indices/{your index public key}/documents/{document ID}
The examples below use the document ID test.
Add a Document
Send a PUT request with document details in JSON format to add or update a document.
Example:
curl --request PUT \
--url https://api.addsearch.com/v2/indices/{your index public key}/documents/test \
--user '{your index public key}:{your index secret key}' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://www.example.com",
"thumbnail_external_src": "https://www.example.com/thumbnail-image.jpg",
"title": "Document title",
"main_content": "Text of your blog post",
"doc_date": "2023-12-31",
"language": "en",
"custom_fields": {
"category": "Post",
"description": "Description for the blog post test document",
"page_rating": 4.5
}
}'
This request adds a document with a URL, thumbnail, title, content, date, language, and custom fields.
Retrieve a Document
Use a GET request to fetch the document content.
Example:
curl --request GET \
--url https://api.addsearch.com/v2/indices/{your index public key}/documents/test \
--user '{your index public key}:{your index secret key}'
Remove a Document
Send a DELETE request to remove a document.
Example:
curl --request DELETE \
--url https://api.addsearch.com/v2/indices/{your index public key}/documents/test \
--user '{your index public key}:{your index secret key}'
Test Search
After indexing documents, you can test searching with a GET request.
Example:
curl --request GET \
--url 'https://api.addsearch.com/v1/search/{your index public key}/?term=test'
Next Steps
For more details, read the Indexing API overview and API usage guidelines.
To implement search UI, see the Search UI library getting started guide.
If you need help, contact our support team.