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

# Conditional requests with InstantSearch Android

> Learn how to make conditional requests with InstantSearch Android.

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>;

By default, InstantSearch sends an initial <SearchRequest /> to Algolia's servers with an empty <SearchQuery />.
This connection helps speed up later requests.

However, sometimes you don't want to perform more network calls than are necessary.
For example, you may want to limit the number of search requests and reduce your overall Algolia usage.
This guide helps you build a UI that prevents this initial request.

## Set Searcher `triggerSearchFor` property

All the `Searcher` implementations such as `HitsSearcher` and `FacetSearcher` provide the `triggerSearchFor` closure which defines the boolean condition for triggering a search operation.
By default has a `null` value so the search will be triggered on each `search()` function call.

* `HitsSearcher`

  ```kotlin Kotlin theme={"system"}
  val searcher = HitsSearcher(
    client = client, 
    indexName = indexName, 
    triggerSearchFor = { query -> query.query?.startsWith("a") == true }
  )
  ```

  ```kotlin Kotlin theme={"system"}
  val searcher = HitsSearcher(
    client = client, 
    indexName = indexName, 
    triggerSearchFor = SearchForQuery.lengthAtLeast(1)  // not empty query
  )
  ```
* `FacetsSearcher`

  ```kotlin Kotlin theme={"system"}
  val searcherForFacet = FacetsSearcher(
    client = client, 
    indexName = indexName, 
    attribute = categories,
    triggerSearchFor = { query, attribute, facetQuery -> facetQuery?.startsWith("a") == true }
  )
  ```

  ```kotlin Kotlin theme={"system"}
  val searcherForFacet = FacetsSearcher(
    client = client, 
    indexName = indexName, 
    attribute = attribute,
    triggerSearchFor = SearchForFacetQuery.lengthAtLeast(1) // not empty query
  )
  ```
* `MultiSearcher`

  ```kotlin Kotlin theme={"system"}
  val searcher = multiSearcher.addHitsSearcher(
    indexName = indexName, 
    triggerSearchFor = SearchForQuery.lengthAtLeast(1)
  )
  ```

  ```kotlin Kotlin theme={"system"}
  val searcher = multiSearcher.addHitsSearcher(
    indexName = indexName,
    attribute = attribute,
    triggerSearchFor = SearchForFacetQuery.lengthAtLeast(1) 
  )
  ```
