--- title: Use wildcards in queries slug: '1580' canonical_url: https://docs.coveo.com/en/1580/ collection: searching-with-coveo source_format: adoc --- # Use wildcards in queries When you use wildcard syntax with the [Search API](https://docs.coveo.com/en/13#operation/planSearchUsingPost), Coveo expands [keywords](https://docs.coveo.com/en/2738/) containing a wildcard character to the possible matching keywords to broaden the [query](https://docs.coveo.com/en/231/). By default, wildcard characters are disabled when using the [Search API](https://docs.coveo.com/en/13#operation/planSearchUsingPost). Coveo supports the wildcard characters `*` and `?`. To enable them, set the `wildcards` query parameter to `true`. However, question mark characters (`?`) are disabled by default. To enable them, set the `questionMark` query parameter to `true`. > **Note** > > With the Search API, developers can enable or disable wildcard match (`wildcards`) independently from the Coveo query syntax (`enableQuerySyntax`), which is set to `true` by default. You can also [leverage wildcard characters](https://docs.coveo.com/en/1897#wildcard-match) in advanced [field](https://docs.coveo.com/en/200/) queries. If you have querying issues, see [Troubleshoot querying issues](https://docs.coveo.com/en/1870/) for troubleshooting guidelines. ## Use the ? wildcard You can use `?` wildcard characters within a search term to allow some variability in your search. This can be useful when you're unsure about the exact spelling for the name of a person, company, or product. See [Using special characters in queries](https://docs.coveo.com/en/2744#question-mark-character). **Examples** ```text gr?y ``` Could return [items](https://docs.coveo.com/en/210/) containing either _gray_ or _grey._ ```text te?t ``` Could return items containing either _text_ or _test,_ but could also return items containing _te4t_ when this term exists in indexed items. ## Use the * wildcard You can use `*` wildcard characters when you want to match all variants of a pattern. You type the fixed part of the pattern and use a wildcard character to expand to the variants. In place of the wildcard, the variants can contain any number of any characters. See [Using special characters in queries](https://docs.coveo.com/en/2744#asterisk-character). **Examples** ```text micro* ``` Could match _Microsoft,_ _microprocessor,_ _microwave,_ _micron,_ etc. ```text THI10* ``` Find all product names starting with _THI10._ ## Use a wildcard in an exact phrase You can use one or both wildcards in conjunction with quotation marks to find variants of a phrase (see [Searching for a phrase](https://docs.coveo.com/en/1686/)). **Example** ```text "fina* scandals 201?" ``` Returns items containing the following phrases : * _financial scandals 2012_ * _final scandals 2010_ ## Use a wildcard with the NEAR operator You can use wildcard characters with the NEAR operator. **Example** ```text fina* NEAR:10 scandals ``` Returns items containing occurrences of words starting with _fina_ that are within ten words from the word _scandals,_ such as in the following phrases: * ...poor financial decisions led to these scandals... * ...number of financial scandals... * ...final decision. Due to the many scandals... ## Wildcard constraints You can't use wildcard characters in combination with an exact match prefix (see [Searching for an exact term](https://docs.coveo.com/en/1815/)). Moreover, wildcard queries can significantly expand a query and so consume more server resources than a typical query. To prevent this: * By default, at least two leading characters must precede the wildcard to restrict the number of wildcard terms candidates. Therefore, a query can't begin with a wildcard. * The query expansion is limited by default to the first 512 wildcard terms found alphabetically. Increasing the maximum number of candidates can lead to performance issues, as more terms will have to be loaded for your wildcard expression. * A given wildcard expression may match a number of candidate items exceeding the maximum allowed by the index. In such a case, the Search API responds with a `WildcardTooGeneral` exception. > **Tip** > > Wildcard queries on the entire content of an index always take longer to return results. > For content where wildcards are appropriate, consider isolating the data in a field, and using the field for the wildcard search (see [Advanced field queries](https://docs.coveo.com/en/1897#wildcard-match)). > When searching in a field, the number of possibilities is smaller, so using the same wildcard expression may return more or even all possible results.