Use Your Pipeline in Your Target App

Add the search functionality to your app and configure how your search results are displayed. The search API endpoint is all you need.

Use the Search Endpoint in Your App

First, generate an API key and save it.

The easiest way is to start with the API Reference documentation:

  1. Go to the Search documentation page.
  2. Enter the necessary parameters:
    • Type the name of the pipeline to use for the search.
    • Type the name of the workspace containing the pipeline you want to use in your target app.
    • Optionally, add filters. (You can use metadata from your documents as filters to narrow down the search. For more information, see Add Search Filters.)
    • Type the queries.
    • In the Bearer field, paste the API key you previously generated.
  3. Choose the programing language that you want to use and copy the code.
A screenshot of the API documentation page where you can select the programming language and the code window updates to show the code in the language you selected.

You can then wrap this code in a function and modify it as needed.

Format Your Search Results

For question answering pipelines, you can highlight the answer in the document, which makes it much easier for the users to spot it. Here is an example of what it looks like:

A screen shot of a search result where the exact answer is highlighted in a passage of text

A highlighted answer in a document

The response for a question answering pipeline contains the exact position of the answer both in the document (offsets_in_document) and in the context (offsets_in_context). You can use it to format how the answers are displayed.

For more information on the answer and document elements, see Haystack documentation for Answer and Document.