# Index

## Module: [implementation](https://utca.knowledgator.com/framework-structure#implementation).datasources.index

***

***

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

Create FAISS index. Subclass of [**Action**](https://utca.knowledgator.com/core/action)**.** Type of [**Action**](https://utca.knowledgator.com/core/action)**\[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**](https://utca.knowledgator.com/core/action)**.** Type of [**Action**](https://utca.knowledgator.com/core/action)**\[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**](https://utca.knowledgator.com/core/action)**.** Type of [**Action**](https://utca.knowledgator.com/core/action)**\[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**](https://utca.knowledgator.com/core/action)**.** Type of [**Action**](https://utca.knowledgator.com/core/action)**\[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;

***

***
