The Glean Indexing API allows customers to put arbitrary content in the search index, making it available for Generative AI applications. This is particularly useful for performing permissions-aware searches over content in internal tools that reside on-premises, as well as for searching over applications that Glean does not currently support first class. Additionally, these APIs allow the customer to push organization data (people info, organization structure, etc.) into Glean.

In addition to documents, the Indexing API also supports indexing custom entities. These are structured key-value content, as opposed to being text heavy like documents. This feature is useful when the information is in the form of structured schema that can be represented as key-value type attributes.

Glean provides advance notice of any planned backwards incompatible changes along with a sunset period for anything that requires developers to adopt the new versions.

Official API Clients

Glean provides official API clients for the Indexing API in multiple languages:

Installing the Indexing API Clients

1

Install the Python client

pip install glean-api-client

Or using Poetry:

poetry add glean-api-client
2

Initialize the client

from glean import Glean
import os

# Initialize with API token
with Glean(
    api_token=os.getenv("GLEAN_INDEXING_API_TOKEN", ""),
) as client:
    # Use the client for indexing operations
    pass
3

Example usage

from glean import Glean, models
import os

with Glean(
    api_token=os.getenv("GLEAN_INDEXING_API_TOKEN", ""),
) as client:
    # Index a document
    response = client.indexing.documents.index(request={
        "datasource": "my-datasource",
        "documents": [
            {
                "id": "doc-123",
                "title": "Sample Document",
                "content": "This is a sample document to index in Glean.",
                "url": "https://example.com/documents/123",
                "permissions": {
                    "users": ["user@example.com"],
                    "groups": ["everyone@example.com"]
                }
            }
        ]
    })
    
    print(response)

For more detailed information, please refer to the API Reference.