# EmbeddingStore

## Overview

EmbeddingStore provides methods to embed text data and perform similarity search using embeddings. It supports asynchronous embedding and blocking search, and can be backed by various embedding store implementations.

## Methods Summarized

| Type                                                       | Name                                                                                                                                              | Summary                                                                                                                                                                                                                                      |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Promise](/reference/servoycore/dev-api/js-lib/promise.md) | [embed(pdfSource, maxSegmentSizeInChars, maxOverlapSizeInChars)](#embed-pdfsource-maxsegmentsizeinchars-maxoverlapsizeinchars)                    | Embeds a PDF document by splitting it into paragraphs of specified size and overlap The text segments are stored in the embedding store and will get metadata from the pdf and if possible also the name of the PDF is set if that is known. |
| [Promise](/reference/servoycore/dev-api/js-lib/promise.md) | [embed(pdfSource, maxSegmentSizeInChars, maxOverlapSizeInChars, metaData)](#embed-pdfsource-maxsegmentsizeinchars-maxoverlapsizeinchars-metadata) | Embeds a PDF document by splitting it into paragraphs of specified size and overlap, with metadata.                                                                                                                                          |
| [Promise](/reference/servoycore/dev-api/js-lib/promise.md) | [embed(data, metaData)](#embed-data-metadata)                                                                                                     | Asynchronously embeds an array of text data with optional metadata and stores the results.                                                                                                                                                   |
| [Promise](/reference/servoycore/dev-api/js-lib/promise.md) | [embedAll(foundSet, textColumns)](#embedall-foundset-textcolumns)                                                                                 | Generates embeddings for all records in the specified foundSet for the given textColumns and stores them in the specified vector column.                                                                                                     |
| [Array](/reference/servoycore/dev-api/js-lib/array.md)     | [search(text)](#search-text)                                                                                                                      | Performs a blocking similarity search for the given text, returning the best matches from the store.                                                                                                                                         |
| [Array](/reference/servoycore/dev-api/js-lib/array.md)     | [search(text, maxResults)](#search-text-maxresults)                                                                                               | Performs a blocking similarity search for the given text, returning the best matches from the store.                                                                                                                                         |

## Methods Detailed

### embed(pdfSource, maxSegmentSizeInChars, maxOverlapSizeInChars)

Embeds a PDF document by splitting it into paragraphs of specified size and overlap The text segments are stored in the embedding store and will get metadata from the pdf and if possible also the name of the PDF is set if that is known.

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **pdfSource** This can be JSFile or String represeting a file\
  path, or byte\[] representing the PDF content.
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **maxSegmentSizeInChars** How many characters per segment we can have.
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **maxOverlapSizeInChars** How many characters of overlap between segments.

**Returns:** [Promise](/reference/servoycore/dev-api/js-lib/promise.md) A Promise resolving to the store

### embed(pdfSource, maxSegmentSizeInChars, maxOverlapSizeInChars, metaData)

Embeds a PDF document by splitting it into paragraphs of specified size and overlap, with metadata. The text segments are stored in the embedding store and will get metadata from the pdf and if possible also the name of the PDF is set if that is known. Also additional metadata can be provided that will be attached to each segment.

**Parameters**

* [Object](/reference/servoycore/dev-api/js-lib/object.md) **pdfSource** This can be JSFile or String represeting a file\
  path, or byte\[] representing the PDF content.
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **maxSegmentSizeInChars** How many characters per segment we can have.
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **maxOverlapSizeInChars** How many characters of overlap between segments.
* [Object](/reference/servoycore/dev-api/js-lib/object.md) **metaData** Metadata to attach to each segment.

**Returns:** [Promise](/reference/servoycore/dev-api/js-lib/promise.md) A Promise resolving to the store

### embed(data, metaData)

Asynchronously embeds an array of text data with optional metadata and stores the results.

**Parameters**

* [Array](/reference/servoycore/dev-api/js-lib/array.md) **data** The array of text strings to embed.
* [Array](/reference/servoycore/dev-api/js-lib/array.md) **metaData** An array of metadata maps, one for each text string (may be\
  null).

**Returns:** [Promise](/reference/servoycore/dev-api/js-lib/promise.md) A Promise resolving to the store

### embedAll(foundSet, textColumns)

Generates embeddings for all records in the specified foundSet for the given textColumns and stores them in the specified vector column.

**Parameters**

* [JSFoundSet](/reference/servoycore/dev-api/database-manager/jsfoundset.md) **foundSet** records in the foundSet are embedded
* [Array](/reference/servoycore/dev-api/js-lib/array.md) **textColumns** columns of the foundSet to embed

**Returns:** [Promise](/reference/servoycore/dev-api/js-lib/promise.md) A Promise resolving with the given foundSet when embeddings are\
stored, or rejects on error.

### search(text)

Performs a blocking similarity search for the given text, returning the best matches from the store. This returns the default 3 results

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **text** The query text to search for.

**Returns:** [Array](/reference/servoycore/dev-api/js-lib/array.md) An array of SearchResult objects representing the best matches.

### search(text, maxResults)

Performs a blocking similarity search for the given text, returning the best matches from the store.

**Parameters**

* [String](/reference/servoycore/dev-api/js-lib/string.md) **text** The query text to search for.
* [Number](/reference/servoycore/dev-api/js-lib/number.md) **maxResults** The maximum number of results to return.

**Returns:** [Array](/reference/servoycore/dev-api/js-lib/array.md) An array of SearchResult objects representing the best matches.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.servoy.com/reference/servoyextensions/server-plugins/ai/embeddingstore.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
