Using Wildcards in Queries

When you use a wildcard syntax in the search box, Coveo expands keywords containing a wildcard character to the possible matching keywords to broaden the query. To use wildcard characters in a query, the enableQuerySyntax option of the Querybox component must be enabled.

Coveo supports wildcard characters * and ?.

See also how you can leverage wildcard characters in advanced field queries (see Advanced Field Queries). If you have querying issues, see Troubleshoot Querying Issues for troubleshooting guidelines.

Using the ? Wildcard

You can use wildcard characters within to allow some variability in your search. It can be useful when you’re unsure about the exact spelling for the name of a person, company, or product. See also Using Special Characters in Queries.

gr?y

Could return items containing either gray or grey.

te?t

Could return items containing either text or test, but could also return items containing te4t when this term exists in indexed items.

Using the * Wildcard

Using wildcard characters can be useful 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 also Using Special Characters in Queries.

micro*

Could match Microsoft, microprocessor, microwave, micron, etc.

THI10*

Find all product names starting with THI10.

Using a Wildcard in an Exact Phrase

You can also one or both wildcards in conjunction with quotation marks to find variants of a phrase (see Searching for a Phrase).

"fina* scandals 201?"

Returns items containing the following phrases :

  • financial scandals 2012

  • final scandals 2010

Using a Wildcard with the NEAR Operator

You can also use wildcard characters with the NEAR operator.

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).

Moreover, wildcard queries can significantly expand a query and consequently 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 32 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.

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). 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.