API API Reference Indexing

This tutorial will guide you through the first steps of using the Indexing API. Here you will learn how to add a document in the index, retrieve document content, remove a document, and more.

You’ll need your index’s site key and secret API key to start. These can be found in the Keys and installation section of your AddSearch dashboard. In the examples below, make sure to replace the {site key} and {secret key} with your specific site and secret keys, as well as the specific URL.

Each document in AddSearch index has a unique ID, a string of characters. An ID of the document is usually specified in the end of the API request URL:
https://api.addsearch.com/v2/indices/{your index public key}/documents/{document ID}
All examples below use the {document ID} as “test”.

Once you have your keys, you can add your first document to your index. To do this, make a curl PUT request like the following:

Creating a document with Title, URL, document date, and custom fields

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",
    "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
  }
}'

Once you’ve added your first document to the index, you can confirm that this was successful and check the contents of that document using a curl GET request:

Getting document’s content

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}'

If you need to delete a file from your index, this can be done with the following curl DELETE request:

Removing a document


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}'

Once the index contains some documents, you can test the search.

Search


curl --request GET \
--url 'https://api.addsearch.com/v1/search/https://api.addsearch.com/v2/indices/{your index public key}?term=test'

With the endpoints mentioned above you can populate your index with content and manage it there. For further details, feel free to check our Indexing API overview or general API usage guidelines.

Once the content is indexed, we recommend proceeding with the implementation using our powerful Search UI library.

If you have questions at any point during your implementation journey, reach out to friendly support team. We are there for you!

Was this helpful?

Need more help?

We’re always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team.