Creating a document by passing attribute values

You can use the Ingestion API to create an index document by passing attribute values. This is useful when you want to quickly add content by passing attribute values, and you don't want to wait for the next scheduled recrawl.

Note

Alternatively, instead of passing attribute values, you can use the Ingestion API to create an index document from a URL or a file by passing attribute extraction logic. You can use an existing document extractor or create a new document extractor.

To use the Ingestion API to create a document by passing attribute values, make a POST call to {base-URL}/ingestion/v1/domains/{domain ID}/sources/{sourceID}/entities/{entityID}/documents?locale={locale}

For the data model of this method and a description of objects and keys, see the Ingestion API reference. You can view your base URL in the Developer Resources section of Search.

Note

When you create an index document, you must pass all the attributes marked as required by the data model. You must also pass all attributes marked as required in Administration > Domain Settings > Attributes section of Sitecore Search.

For example, you want to create an index document with the title, description, type, and url fields.

Here's a sample POST CURL call:

RequestResponse
curl --location 'https://<base-url>/ingestion/v1/domains/<domainID>/sources/<sourceID>/entities/<entity>/documents?locale=<locale>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <api-key>' \
--data '{
    "document": {
        "id": "test_id_123",
        "fields": {
            "title": "Test blog",
            "description": "This is an awesome blog",
            "type": "blog",
            "url": "www.someURL.com"
        }
    }
}'

If your request is successful, you get a 200 response with this body:

RequestResponse
{
    "enqueued": true
}

In the response, enqueued means that Search has added this document to its indexing queue. After a few minutes, you'll see the new document in the Content Collection section of Search.

Do you have some feedback for us?

If you have suggestions for improving this article,