Vectorize and search array allows you to search for the best matching item to a query within an array of strings. For example, searching for the best matching answer to a question in an array of all previously used answers. Note that you can always upload the array as a dataset, enable knowledge and use the knowledge for your analysis.

On this page, we will introduce the Tool step to perform both vectorizing and search in the vector space.

How to use Vectorize and search array step

Add the component

Add the Vectorize and search array step to your Tool (check how to get started with creating a tool). Vectorize and search

A vectorize and search array step requires an array as an input. This array can be entered within the step. However, it is often more practical to fetch the value from an input component or another step output. Use {{variable name}} to provide the data to the Vectorize and search array step.

Vectorize and search

Search query

This is where the search string is provided (i.e. similar to the string typed in Google). It is often more practical to fetch the value from an input component or another step output. Use {{variable name}} to provide the data to the Vectorize and search array step.

Page size

Set to 5 by default, page size indicates the maximum number of entries (from the provided array) to be returned as the search result.

Field

We can specify the target field if the provided array is an array of objects (e.g. an array of JSON dictionaries), and we target a certain field within the objects.

Follow the links below for more information about

Access the step output

The output is a dictionary with two keys results and scores containing the top (i.e. page size) matching results and their search score respectively. Below you can see samples where the default name assigned to the step search_array is used. Note that a step name is different from the step title. Step titles can be found on the top left of steps. A step name is shown on the bottom left, in smaller font and highlighted green.

search_array.results
search_array.scores

Common errors

Not an array

An error similar to the one noted below indicates that the provided input is not an array but one piece of text. To access the best matching part of a large piece of text, we recommend splitting the data. For example, a large user guide can be broken to sections, or its composing pages.

Error:
You will need to split text first