> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/how-to/logic-and-flow/configure-semantic-search.md).

# Configure semantic search

A guide to setting up semantic search

{% hint style="info" %}
**Beta feature**

Semantic search is not generally available yet. Get in touch with your Appfarm contact to discuss early access.
{% endhint %}

Semantic search finds objects by meaning rather than exact words. For example, a search for `how do I reset my password` can return an article about recovering account access even if it uses none of those words. This guide sets up a search field in an app that runs a semantic search and lists the results. To match exact words or filter the results, use [full-text search](https://docs.appfarm.io/how-to/logic-and-flow/configure-full-text-search.md) instead.

## Step 1: Enable semantic search in the data model

In the [data model](https://docs.appfarm.io/reference/data-model.md), select the property you want to search. Under **Semantic search**, select **Semantic search**. Semantic search can be enabled for String and Rich Text properties. See [Semantic search](https://docs.appfarm.io/reference/data-model/object-class-properties.md#semantic-search) for the full list of requirements.

Each environment has its own search index. The index build starts as soon as the change is deployed to an environment, and changes are deployed to Development automatically. To use semantic search in another environment, [deploy](https://docs.appfarm.io/reference/operations/deploy.md) the change there. The build processes every existing object in the object class, so on large object classes it can take some time. Semantic search on the property is unavailable until the build has finished.

## Step 2: App data for search results and search term

Create a runtime-only data source for the search results, based on the object class that holds the property from step 1. Use cardinality many to return several results. With cardinality one, only the best match is returned.

To show how closely each result matches the search term, add a property with data type Float to the data source, for example a runtime property. It will hold the search score.

Create a String [app variable](https://docs.appfarm.io/reference/apps/data/app-variables.md) to hold the search term.

## Step 3: UI for searching and displaying results

In the UI, bind the app variable from step 2 to a [Text edit](https://docs.appfarm.io/library/ui-components/text-edit.md) component. Use the **On Enter** event handler, or add an adornment icon button and use **On Adornment Click**, to run the search action described in step 4.

Add a list, table, or iterating container and bind it to the search results data source. To show the best matches first, sort it by the search score property in descending order. Add a visibility condition to tell the user when no results were found.

## Step 4: Action for semantic search

Add a [Semantic search action node](https://docs.appfarm.io/library/action-nodes/semantic-search.md) to the action from step 3 and set:

* **Data source**: the search results data source from step 2.
* **Search field**: the property you enabled in step 1. Only properties with **Semantic search** selected are listed.
* **Search term**: the app variable from step 2.
* **Search score** (optional): the Float property from step 2.
* **Limit result** (optional): the maximum number of results. The default is `10`.

Each search replaces the contents of the data source, with the most similar objects first. If the search term is empty, the data source is cleared.

{% hint style="info" %}
**Good to know**

If the search runs before the index build from step 1 has finished, the action node fails with an error saying the index is not ready yet. Wait for the build to finish and run the search again.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/how-to/logic-and-flow/configure-semantic-search.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
