﻿---
title: ES|QL QSTR function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/2826/reference/query-languages/esql/functions-operators/search-functions/qstr
products:
  - Elasticsearch
---

# ES|QL QSTR function
<applies-to>
  - Elastic Stack: Generally available since 9.1
  - Elastic Stack: Preview in 9.0
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/2826/reference/query-languages/esql/images/functions/qstr.svg)


## Parameters

<definitions>
  <definition term="query">
    Query string in Lucene query string format.
  </definition>
  <definition term="options">
    (Optional) Additional options for Query String as [function named parameters](/elastic/docs-builder/docs/2826/reference/query-languages/esql/esql-syntax#esql-function-named-params). See [query string query](https://www.elastic.co/elastic/docs-builder/docs/2826/reference/query-languages/query-dsl/query-dsl-query-string-query) for more information.
  </definition>
</definitions>


## Description

Performs a [query string query](https://www.elastic.co/elastic/docs-builder/docs/2826/reference/query-languages/query-dsl/query-dsl-query-string-query). Returns true if the provided query string matches the row.

## Supported types


| query   | options          | result  |
|---------|------------------|---------|
| keyword | named parameters | boolean |
| text    | named parameters | boolean |


### Supported function named parameters

<definitions>
  <definition term="max_determinized_states">
    (integer) Maximum number of automaton states required for the query. Default is 10000.
  </definition>
  <definition term="fuzziness">
    (keyword) Maximum edit distance allowed for matching.
  </definition>
  <definition term="auto_generate_synonyms_phrase_query">
    (boolean) If true, match phrase queries are automatically created for multi-term synonyms. Defaults to true.
  </definition>
  <definition term="phrase_slop">
    (integer) Maximum number of positions allowed between matching tokens for phrases. Defaults to 0 (which means exact matches are required).
  </definition>
  <definition term="default_field">
    (keyword) Default field to search if no field is provided in the query string. Supports wildcards (*).
  </definition>
  <definition term="allow_leading_wildcard">
    (boolean) If true, the wildcard characters * and ? are allowed as the first character of the query string. Defaults to true.
  </definition>
  <definition term="minimum_should_match">
    (string) Minimum number of clauses that must match for a document to be returned.
  </definition>
  <definition term="fuzzy_transpositions">
    (boolean) If true, edits for fuzzy matching include transpositions of two adjacent characters (ab → ba). Defaults to true.
  </definition>
  <definition term="fuzzy_prefix_length">
    (integer) Number of beginning characters left unchanged for fuzzy matching. Defaults to 0.
  </definition>
  <definition term="time_zone">
    (keyword) Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query string to UTC.
  </definition>
  <definition term="lenient">
    (boolean) If false, format-based errors, such as providing a text query value for a numeric field, are returned. Defaults to false.
  </definition>
  <definition term="rewrite">
    (keyword) Method used to rewrite the query.
  </definition>
  <definition term="default_operator">
    (keyword) Default boolean logic used to interpret text in the query string if no operators are specified.
  </definition>
  <definition term="analyzer">
    (keyword) Analyzer used to convert the text in the query value into token. Defaults to the index-time analyzer mapped for the default_field.
  </definition>
  <definition term="fuzzy_max_expansions">
    (integer) Maximum number of terms to which the query expands for fuzzy matching. Defaults to 50.
  </definition>
  <definition term="quote_analyzer">
    (keyword) Analyzer used to convert quoted text in the query string into tokens. Defaults to the search_quote_analyzer mapped for the default_field.
  </definition>
  <definition term="allow_wildcard">
    (boolean) If true, the query attempts to analyze wildcard terms in the query string. Defaults to false.
  </definition>
  <definition term="boost">
    (float) Floating point number used to decrease or increase the relevance scores of the query.
  </definition>
  <definition term="quote_field_suffix">
    (keyword) Suffix appended to quoted text in the query string.
  </definition>
  <definition term="enable_position_increments">
    (boolean) If true, enable position increments in queries constructed from a query_string search. Defaults to true.
  </definition>
  <definition term="fields">
    (keyword) Array of fields to search. Supports wildcards (*).
  </definition>
</definitions>


## Examples

```esql
FROM books
| WHERE QSTR("author: Faulkner")
```


| book_no:keyword | author:text                                        |
|-----------------|----------------------------------------------------|
| 2378            | [Carol Faulkner, Holly Byers Ochoa, Lucretia Mott] |
| 2713            | William Faulkner                                   |
| 2847            | Colleen Faulkner                                   |
| 2883            | William Faulkner                                   |
| 3293            | Danny Faulkner                                     |

<applies-to>
  - Elastic Stack: Generally available since 9.1
</applies-to>

```esql
FROM books
| WHERE QSTR("title: Hobbjt~", {"fuzziness": 2})
```


| book_no:keyword | title:text                         |
|-----------------|------------------------------------|
| 4289            | Poems from the Hobbit              |
| 6405            | The Hobbit or There and Back Again |
| 7480            | The Hobbit                         |