Skip to content

Latest commit

 

History

History
594 lines (407 loc) · 28.6 KB

File metadata and controls

594 lines (407 loc) · 28.6 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.DocumentDefinition;
import com.glean.api_client.glean_api_client.models.components.IndexDocumentRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1IndexdocumentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        IndexDocumentRequest req = IndexDocumentRequest.builder()
                .document(DocumentDefinition.builder()
                    .datasource("<value>")
                    .build())
                .build();

        PostApiIndexV1IndexdocumentResponse res = sdk.indexing().documents().addOrUpdate()
                .request(req)
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
request IndexDocumentRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1IndexdocumentResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.IndexDocumentsRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1IndexdocumentsResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        IndexDocumentsRequest req = IndexDocumentsRequest.builder()
                .datasource("<value>")
                .documents(List.of())
                .build();

        PostApiIndexV1IndexdocumentsResponse res = sdk.indexing().documents().index()
                .request(req)
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
request IndexDocumentsRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1IndexdocumentsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.BulkIndexDocumentsRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1BulkindexdocumentsResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        BulkIndexDocumentsRequest req = BulkIndexDocumentsRequest.builder()
                .uploadId("<id>")
                .datasource("<value>")
                .documents(List.of())
                .build();

        PostApiIndexV1BulkindexdocumentsResponse res = sdk.indexing().documents().bulkIndex()
                .request(req)
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
request BulkIndexDocumentsRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1BulkindexdocumentsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1ProcessalldocumentsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PostApiIndexV1ProcessalldocumentsResponse res = sdk.indexing().documents().processAll()
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
request ProcessAllDocumentsRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1ProcessalldocumentsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

delete

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

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.DeleteDocumentRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1DeletedocumentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        DeleteDocumentRequest req = DeleteDocumentRequest.builder()
                .datasource("<value>")
                .objectType("<value>")
                .id("<id>")
                .build();

        PostApiIndexV1DeletedocumentResponse res = sdk.indexing().documents().delete()
                .request(req)
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description
request DeleteDocumentRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1DeletedocumentResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.DebugDocumentRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1DebugDatasourceDocumentResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PostApiIndexV1DebugDatasourceDocumentResponse res = sdk.indexing().documents().debug()
                .datasource("<value>")
                .debugDocumentRequest(DebugDocumentRequest.builder()
                    .objectType("Article")
                    .docId("art123")
                    .build())
                .call();

        if (res.debugDocumentResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
datasource String ✔️ The datasource to which the document belongs
debugDocumentRequest DebugDocumentRequest ✔️ N/A

Response

PostApiIndexV1DebugDatasourceDocumentResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.DebugDocumentRequest;
import com.glean.api_client.glean_api_client.models.components.DebugDocumentsRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1DebugDatasourceDocumentsResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PostApiIndexV1DebugDatasourceDocumentsResponse res = sdk.indexing().documents().debugMany()
                .datasource("<value>")
                .debugDocumentsRequest(DebugDocumentsRequest.builder()
                    .debugDocuments(List.of(
                        DebugDocumentRequest.builder()
                            .objectType("Article")
                            .docId("art123")
                            .build()))
                    .build())
                .call();

        if (res.debugDocumentsResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
datasource String ✔️ The datasource to which the document belongs
debugDocumentsRequest DebugDocumentsRequest ✔️ N/A

Response

PostApiIndexV1DebugDatasourceDocumentsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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 hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.CheckDocumentAccessRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1CheckdocumentaccessResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        CheckDocumentAccessRequest req = CheckDocumentAccessRequest.builder()
                .datasource("<value>")
                .objectType("<value>")
                .docId("<id>")
                .userEmail("<value>")
                .build();

        PostApiIndexV1CheckdocumentaccessResponse res = sdk.indexing().documents().checkAccess()
                .request(req)
                .call();

        if (res.checkDocumentAccessResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request CheckDocumentAccessRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1CheckdocumentaccessResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 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: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.GetDocumentStatusRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1GetdocumentstatusResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        GetDocumentStatusRequest req = GetDocumentStatusRequest.builder()
                .datasource("<value>")
                .objectType("<value>")
                .docId("<id>")
                .build();

        PostApiIndexV1GetdocumentstatusResponse res = sdk.indexing().documents().status()
                .request(req)
                .call();

        if (res.getDocumentStatusResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request GetDocumentStatusRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1GetdocumentstatusResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

count

Fetches document count for the specified custom datasource.

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

⚠️ DEPRECATED: This will be removed in a future release, please migrate away from it as soon as possible.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.GetDocumentCountRequest;
import com.glean.api_client.glean_api_client.models.operations.PostApiIndexV1GetdocumentcountResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        GetDocumentCountRequest req = GetDocumentCountRequest.builder()
                .datasource("<value>")
                .build();

        PostApiIndexV1GetdocumentcountResponse res = sdk.indexing().documents().count()
                .request(req)
                .call();

        if (res.getDocumentCountResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request GetDocumentCountRequest ✔️ The request object to use for the request.

Response

PostApiIndexV1GetdocumentcountResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*