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

# Implement backend search with InstantSearch on Android

> Implement server-side search in your backend on Android.

<div className="not-prose algolia-flavor-switcher">
  <div className="afs-dropdown">
    <div className="afs-trigger" role="button" tabIndex="0" aria-haspopup="listbox">
      <span className="afs-current">Android</span>

      <svg className="afs-chevron lucide lucide-chevron-down" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
        <path d="m6 9 6 6 6-6" />
      </svg>
    </div>

    <ul className="afs-menu" role="listbox">
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js"><span className="afs-option-name">JavaScript</span><span className="afs-option-lib">InstantSearch.js</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/react"><span className="afs-option-name">React</span><span className="afs-option-lib">React InstantSearch</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/vue"><span className="afs-option-name">Vue</span><span className="afs-option-lib">Vue InstantSearch</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/ios"><span className="afs-option-name">iOS</span><span className="afs-option-lib">InstantSearch iOS</span></a></li>
      <li role="option" aria-selected="true"><a className="afs-option is-current" href="/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/android"><span className="afs-option-name">Android</span><span className="afs-option-lib">InstantSearch Android</span></a></li>
    </ul>
  </div>
</div>

## Who the guide is for

Advanced InstantSearch users may have the need to query Algolia's servers from their backend instead of the frontend, while still being able to reuse InstantSearch widgets. Possible motivations could be for security restrictions, for SEO purposes, or to enrich the data sent by the custom server (for example, fetch Algolia data and data from their own servers). If this sounds appealing to you, feel free to follow this guide. Keep in mind that Algolia recommends frontend search for performance and high availability reasons.

By the end of this guide, you will have learned how to use InstantSearch with your own backend architecture to query Algolia. Even if you're not using Algolia on your backend and still want to benefit from using InstantSearch, then this guide is also for you.

## How InstantSearch works

InstantSearch offers reactive UI widgets that automatically update when new search events occur. Internally, it uses a `Searcher` interface that takes care of making network calls to get search results. The most important methods of that `Searcher` are `setQuery(text: String)`, used to update its search query, and the suspending function `search()` which gets called when InstantSearch requires a new response that you will get from your backend. The next section shows how this works in action:

## Basic implementation of a custom backend

* Implement your own `BackEndSearcher: Searcher<ResponseSearch>`, implementing the [`Searcher`](/doc/api-reference/widgets/instantsearch/android) interface.

  * In `setQuery`, store the given `text` for future requests.
  * In `search`, call your backend and return search results in the `ResponseSearch` format.
  * In `search`, call `search()` asynchronously and return the corresponding `kotlinx.coroutines.Job`.
  * In `cancel`, cancel any pending query.
* Use this `Searcher` in place of `HitsSearcher` in your application.
