Skip to content

Latest commit

 

History

History
615 lines (455 loc) · 33.3 KB

File metadata and controls

615 lines (455 loc) · 33.3 KB

Indexing.Documents

Overview

Available Operations

  • AddOrUpdate - Index document

  • Index - Index documents

  • BulkIndex - Bulk index documents

  • ProcessAll - Schedules the processing of uploaded documents

  • Delete - Delete document

  • Debug - Beta: Get document information

  • DebugMany - Beta: Get information of a batch of documents

  • CheckAccess - Check document access

  • Status - Get document upload and indexing status ⚠️ Deprecated

  • Count - Get document count ⚠️ Deprecated

AddOrUpdate

Adds a document to the index or updates an existing document.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.AddOrUpdate(ctx, components.IndexDocumentRequest{
        Document: components.DocumentDefinition{
            Datasource: "<value>",
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.IndexDocumentRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1IndexdocumentResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Index

Adds or updates multiple documents in the index. Please refer to the bulk indexing documentation for an explanation of when to use this endpoint.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.Index(ctx, components.IndexDocumentsRequest{
        Datasource: "<value>",
        Documents: []components.DocumentDefinition{},
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.IndexDocumentsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1IndexdocumentsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

BulkIndex

Replaces the documents in a datasource using paginated batch API calls. Please refer to the bulk indexing documentation for an explanation of how to use bulk endpoints.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.BulkIndex(ctx, components.BulkIndexDocumentsRequest{
        UploadID: "<id>",
        Datasource: "<value>",
        Documents: []components.DocumentDefinition{},
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.BulkIndexDocumentsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1BulkindexdocumentsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

ProcessAll

Schedules the immediate processing of documents uploaded through the indexing API. By default the uploaded documents will be processed asynchronously but this API can be used to schedule processing of all documents on demand.

If a datasource parameter is specified, processing is limited to that custom datasource. Without it, processing applies to all documents across all custom datasources.

Rate Limits

This endpoint is rate-limited to one usage every 3 hours. Exceeding this limit results in a 429 response code. Here's how the rate limit works:

  1. Calling /processalldocuments for datasource foo prevents another call for foo for 3 hours.
  2. Calling /processalldocuments for datasource foo doesn't affect immediate calls for bar.
  3. Calling /processalldocuments for all datasources prevents any datasource calls for 3 hours.
  4. Calling /processalldocuments for datasource foo doesn't affect immediate calls for all datasources.

For more frequent document processing, contact Glean support.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.ProcessAll(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.ProcessAllDocumentsRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1ProcessalldocumentsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Delete

Deletes the specified document from the index. Succeeds if document is not present.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.Delete(ctx, components.DeleteDocumentRequest{
        Datasource: "<value>",
        ObjectType: "<value>",
        ID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.DeleteDocumentRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1DeletedocumentResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Debug

Gives various information that would help in debugging related to a particular document. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the Troubleshooting tutorial for more information.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.Debug(ctx, "<value>", components.DebugDocumentRequest{
        ObjectType: "Article",
        DocID: "art123",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DebugDocumentResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
datasource string ✔️ The datasource to which the document belongs
debugDocumentRequest components.DebugDocumentRequest ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1DebugDatasourceDocumentResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

DebugMany

Gives various information that would help in debugging related to a batch of documents. Currently in beta, might undergo breaking changes without prior notice.

Tip: Refer to the Troubleshooting tutorial for more information.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.DebugMany(ctx, "<value>", components.DebugDocumentsRequest{
        DebugDocuments: []components.DebugDocumentRequest{
            components.DebugDocumentRequest{
                ObjectType: "Article",
                DocID: "art123",
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.DebugDocumentsResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
datasource string ✔️ The datasource to which the document belongs
debugDocumentsRequest components.DebugDocumentsRequest ✔️ N/A
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1DebugDatasourceDocumentsResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

CheckAccess

Check if a given user has access to access a document in a custom datasource

Tip: Refer to the Troubleshooting tutorial for more information.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.CheckAccess(ctx, components.CheckDocumentAccessRequest{
        Datasource: "<value>",
        ObjectType: "<value>",
        DocID: "<id>",
        UserEmail: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.CheckDocumentAccessResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.CheckDocumentAccessRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1CheckdocumentaccessResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Status

Intended for debugging/validation. Fetches the current upload and indexing status of documents.

Tip: Use /debug/{datasource}/document for richer information.

⚠️ DEPRECATED: Deprecated on 2026-02-03, removal scheduled for 2026-10-15: Endpoint is deprecated.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.Status(ctx, components.GetDocumentStatusRequest{
        Datasource: "<value>",
        ObjectType: "<value>",
        DocID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetDocumentStatusResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.GetDocumentStatusRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1GetdocumentstatusResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*

Count

Fetches document count for the specified custom datasource.

Tip: Use /debug/{datasource}/status for richer information.

⚠️ DEPRECATED: Deprecated on 2026-02-03, removal scheduled for 2026-10-15: Endpoint is deprecated.

Example Usage

package main

import(
	"context"
	"os"
	apiclientgo "github.com/gleanwork/api-client-go"
	"github.com/gleanwork/api-client-go/models/components"
	"log"
)

func main() {
    ctx := context.Background()

    s := apiclientgo.New(
        apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
    )

    res, err := s.Indexing.Documents.Count(ctx, components.GetDocumentCountRequest{
        Datasource: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.GetDocumentCountResponse != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request components.GetDocumentCountRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.PostAPIIndexV1GetdocumentcountResponse, error

Errors

Error Type Status Code Content Type
apierrors.APIError 4XX, 5XX */*