Documents

Documents are JSON objects that hold your data within an Index. This part of the guide focuses on how to use documents through code. We'll go over how to use different endpoints to get, add, update, and delete documents in your Index.

The Document object

A Document is an individual entity or record stored within your Index. Each Document is identified by a unique _id and comprises various fields, each with its corresponding value.

Documents have two special attributes: boost and autocomplete.

  • The boost attribute is used to boost the document's relevance in search results.
  • The autocomplete attribute is automatically populated and updated based on your autocompletion settings.

Attributes

  • Name
    _id
    Type
    string
    Description

    Unique identifier for the document.

  • Name
    boost
    Type
    float
    Description

    Boost value to influence document relevance in search results.

  • Name
    autocomplete
    Type
    array
    Description

    Array of values for autocomplete functionality.

  • Name
    <property-name>
    Type
    <property-type>
    Description

    Any valid JSON object property.

The Document object

{
  "_id": "xgQQXg3hrtjh7AvZ",
  "boost": 1.2,
  "autocomplete": [ ... ]
  // Any valid JSON property.
}

GET/v1/index/{index-name}/document/{document-id}

Get a Document

Use this endpoint to fetch a specific document using its unique identifier.

Parameters

No parameters.

Security

  • Name
    admin
    Type
    API Key
    Description

    This endpoint requires an admin API key.

Returns

Returns the Document object associated with the provided _id.

Request

GET
/v1/index/{index-name}/document/{document-id}
curl -X GET https://sdfzzrn1amg3tbuxb.sigmie.app/v1/index/cosmic-realms/document/xgQQXg3hrtjh7AvZ \
  -H "Content-Type: application/json" \
  -H "X-Sigmie-API-Key: ${api_key}" \
  -H "X-Sigmie-Application: ${application_id}"

Response

200
Ok
{
  "_id": "xgQQXg3hrtjh7AvZ",
  "name": "Stellar Nova",
  "type": "Gas Giant",
  "moons": ["Luna Stardust", "Galaxy Orb"],
  "orbit_distance": "12.3 AU",
  "description": "Stellar Nova is a massive gas giant located in the distant reaches of space."
}

PUT/v1/index/{index-name}/document/{document-id}

Upsert a Document

This endpoint allows you to perform an upsert on a document.

Parameters

  • Name
    boost
    Type
    optional
    Description

    Boost value to influence document relevance in search results.

  • Name
    <property-name>
    Type
    optional
    Description

    Any valid JSON object property.

Security

  • Name
    admin
    Type
    API Key
    Description

    This endpoint requires an admin API key.

Returns

Returns the newly created Document object.

Request

PUT
/v1/index/{index-name}/document/{document-id}
curl -X PUT https://sdfzzrn1amg3tbuxb.sigmie.app/v1/index/cosmic-realms/document/dcJSIokB176iWt9Rv \
  -H "Content-Type: application/json" \
  -H "X-Sigmie-API-Key: ${api_key}" \
  -H "X-Sigmie-Application: ${application_id}" \
  -d '{
    "name": "Nebula Prime",
    "type": "Nebula",
    "location": "Outer Spiral Arm",
    "boost": 1.2,
    "size": "Gigantic",
    "description": "Nebula Prime is a mesmerizing nebula located in the Outer Spiral Arm of the galaxy."
  }'

Response

201
Created
{
  "_id": "dcJSIokB176iWt9Rv",
  "name": "Nebula Prime",
  "type": "Nebula",
  "location": "Outer Spiral Arm",
  "boost": 1.2,
  "size": "Gigantic",
  "description": "Nebula Prime is a mesmerizing nebula located in the Outer Spiral Arm of the galaxy."
}

PATCH/v1/index/{index-name}/document/{document-id}

Patch a Document

This endpoint allows you to perform a partial update on a document.

Parameters

  • Name
    boost
    Type
    optional
    Description

    Boost value to influence document relevance in search results.

  • Name
    <property-name>
    Type
    optional
    Description

    Any valid JSON object property.

Security

  • Name
    admin
    Type
    API Key
    Description

    This endpoint requires an admin API key.

Returns

Returns the updated Document object after the patch has been applied.

Request

PATCH
/v1/index/{index-name}/document/{document-id}
curl -X PATCH https://sdfzzrn1amg3tbuxb.sigmie.app/v1/index/cosmic-realms/document/dcJSIokB176iWt9Rv \
  -H "Content-Type: application/json" \
  -H "X-Sigmie-API-Key: ${api_key}" \
  -H "X-Sigmie-Application: ${application_id}" \
  -d '{ "name": "Nebula Prime" }'

Response

200
Ok
{
  "_id": "dcJSIokB176iWt9Rv",
  "name": "Nebula Prime",
  "type": "Nebula",
  "location": "Outer Spiral Arm",
  "size": "Enormous",
  "description": "Nebula Prime is a mesmerizing nebula located in the Outer Spiral Arm of the galaxy."
}

DELETE/v1/index/{index-name}/document/{document-id}

Delete a Document

This endpoint allows you to delete a document by providing the document id.

Parameters

No parameters.

Security

  • Name
    admin
    Type
    API Key
    Description

    This endpoint requires an admin API key.

Returns

Returns a JSON object that includes the _id of the Document that was deleted.

Request

DELETE
/v1/index/{index-name}/document/{document-id}
curl -X DELETE https://sdfzzrn1amg3tbuxb.sigmie.app/v1/index/cosmic-realms/document/xgQQXg3hrtjh7AvZ \
  -H "Content-Type: application/json" \
  -H "X-Sigmie-API-Key: ${api_key}" \
  -H "X-Sigmie-Application: ${application_id}"

Response

202
Accepted
{
  "_id": "xgQQXg3hrtjh7AvZ"
}