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

# query

> Search query string

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="string" default="" scope="search" />

## Usage

The `query` parameter represents the **query string** Algolia matches against your index.

For an overview of how Algolia interprets and ranks queries,
see [Relevance overview](/doc/guides/managing-results/relevance-overview).

### Formatting rules

* An empty string (`""`) returns all records, sorted by [`customRanking`](/doc/api-reference/api-parameters/customRanking).
* Query strings can be up to 512 bytes long.
* Boolean operators (`AND`, `OR`, `NOT`) aren't supported in the query string.
* Multi-word queries require all words to match.
  For example, `hot dog`  only returns records containing both `hot` and `dog`.

### Related features and parameters

* **Boolean logic:** use [filters](/doc/guides/managing-results/refine-results/filtering) or [`optionalWords`](/doc/api-reference/api-parameters/optionalWords).
* **Broader matching when [no results](/doc/guides/building-search-ui/resources/ui-kit/js#empty-query-state) are found:** use [`removeWordsIfNoResults`](/doc/api-reference/api-parameters/removeWordsIfNoResults).
* **Phrase exclusion or exact matching:** use [`advancedSyntax`](/doc/api-reference/api-parameters/advancedSyntax).

## Example

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SearchSingleIndexAsync<Hit>(
        "INDEX_NAME",
        new SearchParams(new SearchParamsObject { Query = "phone" })
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          query: "phone",
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
        "INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
        search.NewEmptySearchParamsObject().SetQuery("phone"))))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex("INDEX_NAME", new SearchParamsObject().setQuery("phone"), Hit.class);
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({ indexName: 'indexName', searchParams: { query: 'phone' } });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = SearchParamsObject(query = "phone"),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['query' => 'phone',
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "query": "phone",
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index("INDEX_NAME", Algolia::Search::SearchParamsObject.new(query: "phone"))
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = Some(
            SearchParamsObject(
              query = Some("phone")
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response: SearchResponse<Hit> = try await client.searchSingleIndex(
          indexName: "INDEX_NAME",
          searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(query: "phone"))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.search(
        new Query("shirt")
      );
      ```

      ```go Go theme={"system"}
      res, err := index.Search("shirt")
      ```

      ```java Java theme={"system"}
      index.search(
        new Query("shirt")
      );
      ```

      ```js JavaScript theme={"system"}
      index.search("shirt").then(({ hits }) => {
        console.log(hits);
      });
      ```

      ```kotlin Kotlin theme={"system"}
      index.search(Query("shirt"))
      ```

      ```php PHP theme={"system"}
      $results = $index->search('shirt');
      ```

      ```python Python theme={"system"}
      results = index.search("shirt")
      ```

      ```ruby Ruby theme={"system"}
      results = index.search("shirt")
      ```

      ```scala Scala theme={"system"}
      client.execute {
        search into "YourIndex" query Query(
          query = Some("shirt")
        )
      }
      ```

      ```swift Swift theme={"system"}
      index.search(query: "shirt") { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
