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.
Properties with an underscore _
prefix are reserved for internal use and
can't be used.
The Document object
{
"_id": "xgQQXg3hrtjh7AvZ",
"boost": 1.2,
"autocomplete": [ ... ]
// Any valid JSON property.
}
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
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
{
"_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."
}
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
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
{
"_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 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
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
{
"_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 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
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
{
"_id": "xgQQXg3hrtjh7AvZ"
}