> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Backend search with an API client

> Understand the search Algolia provides out of the box.

export const SearchRequest = () => <Tooltip tip="A search request is a single HTTP call to the Algolia Search API that can run one or more search operations. It can include multiple queries, for example, when querying several indices at once.">
    search request
  </Tooltip>;

export const SearchQuery = () => <Tooltip tip="The text users enter into a search box. In the Search API, this corresponds to the query parameter. A search query is often used with filters, facets, and other parameters, but these aren't part of the query text itself.">
    search query
  </Tooltip>;

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </Tooltip>;

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

export const Filter = () => <Tooltip tip="A filter is a condition that limits which records Algolia returns. Filters often use one or more facet-value pairs, such as brand:Apple AND color:red. You can also filter by numeric values, dates, tags, booleans, or geographic constraints." cta="Filtering" href="/doc/guides/managing-results/refine-results/faceting">
    filter
  </Tooltip>;

export const Facet = () => <Tooltip tip="An attribute in your records that lets users filter or group results (for example, by color, brand, or price)." cta="Faceting" href="/doc/guides/managing-results/refine-results/faceting">
    facet
  </Tooltip>;

To query your Algolia <Index />, you need an Application ID and a valid API key.
You can find them in the Algolia dashboard's [API Keys](https://dashboard.algolia.com/account/api-keys/) section.
These credentials let you connect to Algolia and perform operations on your data.

Use one of Algolia's [API clients](/doc/libraries/sdk) to guarantee end-to-end reliability.

## Basic queries

To retrieve results from Algolia, use the [Search index](/doc/libraries/sdk/v1/methods/search) method. Querying Algolia involves:

* Choosing the index to query against
* Sending the query string
* Adding optional parameters

Along with the user's text, you can provide any number of [query parameters](/doc/api-reference/api-parameters) in your <SearchQuery />.
Some override an index's settings, such as disabling typo tolerance.
Others enrich the search, such as filtering.
Adding optional parameters can alter textual relevance behavior at query-time.
For example, it's possible to define stop words or change plurals behavior only for certain queries.

<Note>
  Algolia recommends querying directly from the user's browser, mobile device, or client to ensure optimal performance by reducing latency (and benefiting from offloading your servers).
</Note>

Here's a basic query example:

```js JavaScript icon="code" theme={"system"}
index.search("query", {
  ignorePlurals: true,
});
```

### Empty queries

Sometimes, you might not need to pass in a textual query.
It's possible to retrieve results from Algolia by specifying an index and other optional parameters (most likely, a <Filter />).
In this way, it's possible to use Algolia beyond a standard "search results" experience.
For example, one common use case is to use filtering capabilities to generate category landing pages.

### Browsing your index

Algolia lets you fetch all <Records /> in an index using the [`browse`](/doc/libraries/sdk/v1/methods/browse) method.
If you need to retrieve the full contents of your index (for backup, SEO purposes or for running a script on it),
use the [`browse`](/doc/libraries/sdk/v1/methods/browse) method instead of [`search`](/doc/libraries/sdk/v1/methods/search), as [`search`](/doc/libraries/sdk/v1/methods/search) is optimized for speed.
Results are returned ranked by attributes and custom ranking. Additionally, [`browse`](/doc/libraries/sdk/v1/methods/browse) supports most search parameters, meaning you can easily apply filters to retrieve a subset of results.

### Multiple indices / multiple queries

[Multiple indices](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/concepts/one-or-more-indices) are used when you have different kinds of data (movies + actors), or you need to display results with different rankings. You can do this by using the same query / response logic, one for each index or query.

## Response format

If a query is successful, your <SearchRequest /> will generate a JSON response in return.
This response contains both the matching results (*hits*) as well as other information useful for building a full-fledged search experience (for example, facets, highlighting, hits count, paging, and more).

For more information, see [Understand the API response](/doc/guides/building-search-ui/going-further/backend-search/in-depth/understanding-the-api-response/vue)

### Highlighting and snippeting

Highlighting is an important tool to demonstrate to searchers *why* a result matched their query by providing different styling to all matched query words.
By default, highlighting is enabled on all searchable attributes.

Snippets only return a portion of the matched attribute: the matched words and some words around them. Unlike highlighting, snippeting must be proactively enabled for each attribute you wish to snippet, although you can set the value `*` to snippet all attributes.

### Pagination

Pagination gives you full control over how you retrieve query results. You can implement standard paging or retrieve specific record subsets that ignore page boundaries (infinite scrolling).

You can set pagination defaults at indexing time and override them at query time.

### Faceting

Facets are used to create categories on a select group of attributes.
For example, useful facets for an index of books might be author and genre.
Additionally, Algolia calculates the count of records for each <Facet />.
You can display facets and facet counts in the UI to let users filter results (for example, by author or genre).

### Search for facet values

Closely tied to *faceting* is *searching* for facet values.
With this powerful feature,
you give your user the ability to navigate through maybe hundreds of different facet values.
And because they can search, you are no longer concerned about creating too many values—they will find what they need.

## See also

* [Faceting](/doc/guides/managing-results/refine-results/faceting)
* [Paginate results](/doc/guides/building-search-ui/ui-and-ux-patterns/pagination/react)
* [Highlighting](/doc/guides/building-search-ui/ui-and-ux-patterns/highlighting-snippeting/react)
* [Search for facet values](/doc/libraries/sdk/v1/methods/search-for-facet-values)
