Associates custom metadata with a specific document. Custom metadata enables you to enrich documents with additional structured information that can be used for search, filtering, and faceting.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.indexing.custom_metadata.upsert(doc_id="<id>", group_name="<value>", custom_metadata=[])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
doc_id |
str |
✔️ |
Unique Glean identifier of the document |
group_name |
str |
✔️ |
Name of the metadata group as specified while adding schema |
custom_metadata |
List[models.CustomProperty] |
✔️ |
Array of custom metadata key-value pairs |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] |
➖ |
An optional server URL to use. |
models.SuccessResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorInfoResponse |
400, 401, 404, 429 |
application/json |
| errors.ErrorInfoResponse |
500 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Removes all custom metadata for the specified metadata group from a document.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.indexing.custom_metadata.delete(doc_id="<id>", group_name="<value>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
doc_id |
str |
✔️ |
Unique Glean identifier of the document |
group_name |
str |
✔️ |
Name of the metadata group as specified while adding schema |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] |
➖ |
An optional server URL to use. |
models.SuccessResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorInfoResponse |
400, 401, 404, 429 |
application/json |
| errors.ErrorInfoResponse |
500 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Retrieves the current schema definition for a metadata group.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.indexing.custom_metadata.get_schema(group_name="<value>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
group_name |
str |
✔️ |
Name of the metadata group schema |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] |
➖ |
An optional server URL to use. |
models.CustomMetadataSchema
| Error Type |
Status Code |
Content Type |
| errors.ErrorInfoResponse |
401, 404, 429 |
application/json |
| errors.ErrorInfoResponse |
500 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Defines or updates the schema for a metadata group. Schemas should be defined before indexing metadata.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.indexing.custom_metadata.upsert_schema(group_name="<value>", metadata_keys=[])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
group_name |
str |
✔️ |
Name of the metadata group schema |
metadata_keys |
List[models.CustomMetadataPropertyDefinition] |
✔️ |
Array of metadata key definitions |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] |
➖ |
An optional server URL to use. |
models.SuccessResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorInfoResponse |
400, 401, 409, 429 |
application/json |
| errors.ErrorInfoResponse |
500 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Deletes the schema definition for a metadata group. This does not delete existing metadata values on documents.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.indexing.custom_metadata.delete_schema(group_name="<value>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
group_name |
str |
✔️ |
Name of the metadata group schema |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] |
➖ |
An optional server URL to use. |
models.SuccessResponse
| Error Type |
Status Code |
Content Type |
| errors.ErrorInfoResponse |
400, 401, 404, 429 |
application/json |
| errors.ErrorInfoResponse |
500 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |