Skip to content

Latest commit

 

History

History
230 lines (152 loc) · 14.5 KB

File metadata and controls

230 lines (152 loc) · 14.5 KB

Indexing.CustomMetadata

Overview

Available Operations

upsert

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.

Example Usage

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)

Parameters

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.

Response

models.SuccessResponse

Errors

Error Type Status Code Content Type
errors.ErrorInfoResponse 400, 401, 404, 429 application/json
errors.ErrorInfoResponse 500 application/json
errors.GleanError 4XX, 5XX */*

delete

Removes all custom metadata for the specified metadata group from a document.

Example Usage

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)

Parameters

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.

Response

models.SuccessResponse

Errors

Error Type Status Code Content Type
errors.ErrorInfoResponse 400, 401, 404, 429 application/json
errors.ErrorInfoResponse 500 application/json
errors.GleanError 4XX, 5XX */*

get_schema

Retrieves the current schema definition for a metadata group.

Example Usage

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)

Parameters

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.

Response

models.CustomMetadataSchema

Errors

Error Type Status Code Content Type
errors.ErrorInfoResponse 401, 404, 429 application/json
errors.ErrorInfoResponse 500 application/json
errors.GleanError 4XX, 5XX */*

upsert_schema

Defines or updates the schema for a metadata group. Schemas should be defined before indexing metadata.

Example Usage

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)

Parameters

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.

Response

models.SuccessResponse

Errors

Error Type Status Code Content Type
errors.ErrorInfoResponse 400, 401, 409, 429 application/json
errors.ErrorInfoResponse 500 application/json
errors.GleanError 4XX, 5XX */*

delete_schema

Deletes the schema definition for a metadata group. This does not delete existing metadata values on documents.

Example Usage

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)

Parameters

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.

Response

models.SuccessResponse

Errors

Error Type Status Code Content Type
errors.ErrorInfoResponse 400, 401, 404, 429 application/json
errors.ErrorInfoResponse 500 application/json
errors.GleanError 4XX, 5XX */*