> For the complete documentation index, see [llms.txt](https://utca.knowledgator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utca.knowledgator.com/datasources/index.md).

# Index

Actions for handling index objects

## Module: [implementation](/framework-structure.md#implementation).datasources.index

***

***

## <mark style="color:green;">IndexCreate</mark>

Create FAISS index. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Any, Dict\[str, Any]]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**dataset\_dimensions**</mark>**&#x20;(int, optional):** Dataset dimension. Defaults to 1024.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Any):** Ignored.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"index"**</mark> **(faiss.IndexFlatL2):** Created index.

***

***

***

## <mark style="color:green;">IndexData</mark>

Index data. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Dict\[str, Any], None]**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):**\
  Expected keys:
  * <mark style="color:red;">**"index"**</mark>**&#x20;(faiss.IndexFlatL2):** Index to update;
  * <mark style="color:red;">**"dataset"**</mark>**&#x20;(Any):** Data to index;

***

***

***

## <mark style="color:green;">IndexSearch</mark>

Search index. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Dict\[str, Any], Dict\[str, Any]]**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**results\_count**</mark>**&#x20;(int, optional):** How many results to return. Defaults to 1.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):**\
  Expected keys:
  * <mark style="color:red;">**"index"**</mark>**&#x20;(faiss.IndexFlatL2):** Index to search;
  * <mark style="color:red;">**"query"**</mark>**&#x20;(Any):** Query to search;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"search\_results"**</mark>**&#x20;(Dict\[str, Any]):** Results of search. Results include:&#x20;
    * <mark style="color:purple;">**"distances"**</mark>**&#x20;(List\[float]):** List of distances;
    * <mark style="color:purple;">**"indexes"**</mark>**&#x20;(List\[Any]):** Indexes of indexed data;

***

***

***

## <mark style="color:green;">GetTextsByIndexes</mark>

Get texts from resulted indexes. Subclass of [**Action**](/core/action.md)**.** Type of [**Action**](/core/action.md)**\[Dict\[str, Any], Dict\[str, Any]]**

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):**\
  Expected keys:
  * <mark style="color:red;">**"texts"**</mark>**&#x20;(List\[str]):** Indexed texts;
  * <mark style="color:red;">**"search\_results"**</mark>**&#x20;(Dict\[str, Any]):** Results of search. Results include:&#x20;
    * <mark style="color:purple;">**"distances"**</mark>**&#x20;(List\[float]):** List of distances;
    * <mark style="color:purple;">**"indexes"**</mark>**&#x20;(List\[Any]):** Indexes of indexed data;

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:
  * <mark style="color:red;">**"search\_results"**</mark>**&#x20;(Dict\[str, Any]):** Results of search. Results include:&#x20;
    * <mark style="color:purple;">**"distances"**</mark>**&#x20;(List\[float]):** List of distances;
    * <mark style="color:purple;">**"indexes"**</mark>**&#x20;(List\[Any]):** Indexes of indexed data;
    * <mark style="color:purple;">**"texts"**</mark>**&#x20;(List\[str]):** Texts of results;

***

***
