@grepvine/sdk
    Preparing search index...

    Class Documents

    The documents of an index, reached as client.documents.

    Hierarchy

    • Documents
      • Documents
    Index
    • Delete a batch of documents

      Deletes up to 2,048 documents. Each document is deleted on its own: a document that does not exist or whose precondition fails is not deleted, the others are, and the result of each document says which happened. Retrying with the same Idempotency-Key returns the same results.

      Type Parameters

      • ThrowOnError extends boolean = true

      Parameters

      • parameters: {
            "Idempotency-Key"?: string;
            index: string;
            objects: DeleteObjectRecord[];
            organization: string;
        }
      • Optionaloptions: Options<never, ThrowOnError, unknown>

      Returns RequestResult<DeleteObjectsResponses, DeleteObjectsErrors, ThrowOnError, "data">

    • Store one document

      Stores one document of at most 1 GiB. Content that is valid UTF-8 and at most 100 MiB is searchable. Any other content, such as an image or a larger file, is stored, listed, and served by the document endpoints but is never matched by a search. The searchable field of a listing reports which applies.

      Type Parameters

      • ThrowOnError extends boolean = true

      Parameters

      • parameters: {
            content: Blob | File;
            "Idempotency-Key"?: string;
            "If-Match"?: string;
            "If-None-Match"?: "*";
            index: string;
            key: string;
            metadata?: string;
            organization: string;
        }
      • Optionaloptions: Options<never, ThrowOnError, unknown>

      Returns RequestResult<PutDocumentResponses, PutDocumentErrors, ThrowOnError, "data">

    • Store a batch of documents

      Stores up to 2,048 documents. Each document is stored on its own: a document whose precondition fails is not stored, the others are, and the result of each document says which happened. Retrying with the same Idempotency-Key returns the same results and stores any document an interrupted attempt did not reach. Batch content is text carried as JSON strings, so every document stored this way is searchable. Store binary content, or a document over 16 MiB, with the single-document endpoint. The body may be sent with Content-Encoding: gzip; the service decodes it before applying the limits below, and answers any other content encoding with 415 unsupported_content_encoding.

      Type Parameters

      • ThrowOnError extends boolean = true

      Parameters

      • parameters: {
            body: string;
            "Idempotency-Key"?: string;
            index: string;
            organization: string;
        }
      • Optionaloptions: Options<never, ThrowOnError, unknown>

      Returns RequestResult<PutObjectsResponses, PutObjectsErrors, ThrowOnError, "data">

    • Store any number of documents and return one result per document, in input order.

      Text travels as NDJSON in batches of up to 2,048 documents and 16 MiB; other content travels one document at a time. Every document gets path (its key) and size metadata, which metadata can override. Each document is stored on its own: one whose ifMatch or ifNoneMatch condition fails is left unchanged and its result carries an error.

      A failure after part of the documents were stored throws PartialBatchError. With idempotencyKey (16 to 120 characters), repeating the call with the same documents finishes it without storing any document twice.

      const results = await client.documents.putMany({
      organization: "acme",
      index: "docs",
      documents: [{ key: "a.md", content: "# A", metadata: { kind: "guide" } }],
      });

      Parameters

      • parameters: {
            documents: Iterable<DocumentInput>;
            idempotencyKey?: string;
            index: string;
            organization: string;
            signal?: AbortSignal;
        }

      Returns Promise<MutationResult[]>