# DocumentSearchTools

Namespace: **Wisej.AI.Tools**

Assembly: **Wisej.AI** (3.5.0.0)

* [ToolsContainer](/ai/components/api/tools/wisej.ai.tools.toolscontainer.md)
  * [DocumentSearchTools](/ai/components/api/tools/wisej.ai.tools.documentsearchtools.md)

Provides tools for searching and managing documents within a specified collection.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DocumentSearchTools : ToolsContainer
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DocumentSearchTools
    Inherits ToolsContainer
```

{% endtab %}
{% endtabs %}

This class allows for embedding questions, querying documents, listing documents, and summarizing document content. It utilizes these services: [ITokenizerService](/ai/components/api/services/itokenizerservice.md), [IEmbeddingStorageService](/ai/components/api/services/iembeddingstorageservice.md).

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) DocumentSearchTools(collectionName, filter)

Initializes a new instance of the [DocumentSearchTools](/ai/components/api/tools/wisej.ai.tools.documentsearchtools.md) class.

| Name               | Type                                                                                     | Description                                                      |
| ------------------ | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| **collectionName** | [String](https://docs.microsoft.com/dotnet/api/system.string)                            | The name of the document collection. Default is an empty string. |
| **filter**         | [Predicate\<EmbeddedDocument>](https://docs.microsoft.com/dotnet/api/system.predicate-1) | A predicate to filter embedded documents. Default is null.       |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  Thrown when *collectionName* is null.

## Properties

### ![](/files/ptrKjmmRoQB76pvrIqh0) CollectionName

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the name of the document collection. (Default: `null`)

### ![](/files/KL0Ik37djZRr8a07Wopd) EmbeddingGenerationService

[IEmbeddingGenerationService](/ai/components/api/services/iembeddinggenerationservice.md): Gets or sets the embedding generation service used for embedding questions.

### ![](/files/KL0Ik37djZRr8a07Wopd) EmbeddingStorageService

[IEmbeddingStorageService](/ai/components/api/services/iembeddingstorageservice.md): Gets or sets the embedding storage service used for storing and retrieving embedded documents.

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxClusters

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Get or sets the maximum number of vector clusters to generate when performing summarization tasks. (Default: `5`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxContextTokens

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of context tokens. (Default: `4096`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxDocumentsSearch

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of documents that can be returned. (Default: `100`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MinSimilarity

[Single](https://docs.microsoft.com/dotnet/api/system.single): Gets or sets the minimum similarity threshold for document retrieval. (Default: `0.25`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) RerankingEnabled

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether reranking is enabled. (Default: `False`)

### ![](/files/KL0Ik37djZRr8a07Wopd) RerankingService

[IRerankingService](/ai/components/api/services/irerankingservice.md): Gets or sets the reranking service.

### ![](/files/KL0Ik37djZRr8a07Wopd) TokenizerService

[ITokenizerService](/ai/components/api/services/itokenizerservice.md): Gets or sets the tokenizer service used for truncating content to fit within the maximum context tokens.

### ![](/files/ptrKjmmRoQB76pvrIqh0) TopN

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the number of top chunks to retrieve. (Default: `10`)

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) EmbedQuestionAsync(question)

Asynchronously generates an embedding for the specified question.

| Parameter    | Type                                                          | Description                                             |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The question to be embedded. Must not be null or empty. |

**Returns:** [Task\<Embedding>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the generated [Embedding](/ai/components/api/embeddings/wisej.ai.embeddings.embedding.md) for the question, or `null` if the input is invalid.

This method checks if the provided *question* is null or empty and returns `null` if so. Otherwise, it delegates the embedding generation to the `EmbeddingGenerationService`.

### ![](/files/KL0Ik37djZRr8a07Wopd) list\_all\_documents()

Lists all documents in the collection.

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains a list of document names as a string.

### ![](/files/KL0Ik37djZRr8a07Wopd) query\_all\_documents(question)

Queries all documents based on the provided question.

| Parameter    | Type                                                          | Description                          |
| ------------ | ------------------------------------------------------------- | ------------------------------------ |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The question to query documents for. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the query results as a string.

This method retrieves all documents that match the embedded question.

### ![](/files/KL0Ik37djZRr8a07Wopd) query\_single\_document(document\_name, question)

Queries a single document based on the provided document name and question.

| Parameter          | Type                                                          | Description                             |
| ------------------ | ------------------------------------------------------------- | --------------------------------------- |
| **document\_name** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the document to query.      |
| **question**       | [String](https://docs.microsoft.com/dotnet/api/system.string) | The question to query the document for. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the query result as a string.

### ![](/files/KL0Ik37djZRr8a07Wopd) read\_documents\_metadata(document\_names)

Reads metadata for the specified documents.

| Parameter           | Type                                                              | Description                                      |
| ------------------- | ----------------------------------------------------------------- | ------------------------------------------------ |
| **document\_names** | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of document names to read metadata for. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the metadata as a string.

### ![](/files/KL0Ik37djZRr8a07Wopd) RerankAsync(question, chunks)

Asynchronously reranks the provided text chunks based on their relevance to the given question.

| Parameter    | Type                                                              | Description                                   |
| ------------ | ----------------------------------------------------------------- | --------------------------------------------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The question used as the basis for reranking. |
| **chunks**   | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of text chunks to be reranked.       |

**Returns:** [Task\<String\[\]>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains an array of reranked text chunks.

This method is intended to be overridden in derived classes to implement custom reranking logic. The method should return the *chunks* array reordered by relevance to the *question* .

### ![](/files/KL0Ik37djZRr8a07Wopd) summarize\_document(document\_name)

Summarizes the content of a specified document.

| Parameter          | Type                                                          | Description                            |
| ------------------ | ------------------------------------------------------------- | -------------------------------------- |
| **document\_name** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the document to summarize. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the summary as a string.

## Implements

| Name                                                                          | Description                                                                                           |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [IToolsContainer](/ai/components/api/tools/wisej.ai.tools.itoolscontainer.md) | Represents a container for tools, providing access to a hub, adapter, and a collection of parameters. |


---

# 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.wisej.com/ai/components/api/tools/wisej.ai.tools.documentsearchtools.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.
