Querying the indexed data with AI Answer can be done in various ways. ReactiveSearch provides three ways to query the data along with various levels of access. ReactiveSearch even provides support for modifying the way the query endpoints behave by using pipelines (more on this later on in this doc).

Ways to query

From a top-level perspective, there are three main ways to query the data:

  • With ReactiveSearch UI components
  • With ReactiveSearch API
  • With ReactiveSearch Pipelines

Querying with AI Answer enabled

With UI Components

ReactiveSearch provides a state-of-the art library that uses ReactiveSearch API under the hood and makes development experience much faster. With the UI library, a search UI can be built and brought up within a few minutes.

Check out more demos of using ReactiveSearch

With UI components that ReactiveSearch provides, it's easy to quickly get started with using AI Answer.

Library Component Link
React Searchbox with AI Answer Read more
React AI Answer Read more

With API

ReactiveSearch API acts as the gateway for accessing the data. It's an easy-to-use API that can be as simple as a search query and get as complex as multiple faceted queries with various query dependencies.

Following is an example ReactiveSearch call that enables the AI Answer feature by using the enableAI flag in the call. Once the request resolves, the AISessionId can be then used to fetch the answers, ask follow-up questions, get analytics etc.

From the above request, find the AISessionId and put it in the following embed to fetch the AI Answer response.

In the following, a GET /_ai/{AISessionId} is being made to fetch the answer for the session ID returned in the ReactiveSearch call

Learn more about the endpoints ReactiveSearch provides for interacting with AI

With Pipeline

NOTE: This is aimed at developers only who want to modify the behavior of the ReactiveSearch endpoint (or any other endpoint) to suit their needs.

ReactiveSearch Pipelines pack a lot of features and functionalities that makes it possible to alter the behaviour of the ReactiveSearch call as well as add extra steps in the flow.

AI Answer is provided as a pre-built stage for use in a pipeline, following is how AI Answer stage can be used with ReactiveSearch stage:

Copy
- id: reactivesearch
  use: reactivesearchQuery
  continueOnError: false
- id: elastic search
  use: elasticsearchQuery
  continueOnError: false
- id: ai answer
  use: AIAnswer
  inputs:
    docTemplate: "${source.title} is ${source.overview} with url: ${source.backdrop_path}"
    apiKey: "{{openAIApiKey}}"

Learn more about using pipelines to get AI Answers with ReactiveSearch