Advanced field queries

The Coveo query syntax includes special field operators to perform advanced matches. These advanced field queries perform the match directly on field values rather than through the index, as is the case for regular field queries.

The benefit of advanced field queries is that you can search field values for occurrences of special characters which are typically not searchable because they’re not indexed (for example, dots, dashes, parentheses, etc.), and which can act as search prefixes or operators.

You can only use an advanced field query if the queried field is a facet field.

Advanced field query search results will return within 1 second. However, when the number of items, possible field values, or complexity of the matching expression (for regular expressions) increases, or when field values aren’t loaded in cache memory, this will take more time.

Advanced field query syntax

The advanced field query syntax is:

@<FIELD_NAME> <ADVANCED_FIELD_OPERATOR> "<VALUE>"1

Advanced field operator Description
*= Wildcard Match
~= Fuzzy Match
%= Phonetic Match
/= Regular Expression Match
  • The wildcard, fuzzy, phonetic, and regular expression advanced field queries are case-insensitive and aren’t subject to stemming.

1: Space characters on either side of the operator are optional.

Wildcard match

Wildcard matches broaden the search results by introducing some variability into the query string. The wildcard match operator (*=) interprets any wildcard characters (?, *) which are present in the field value (“<VALUE>”) without the restrictions that usually apply when you use wildcard characters in an index query.

You can use one or more wildcard characters anywhere in the field value, and all possible combinations will be matched.

  • @author *= "*son"

    Matches would include: E. Johnson, ejohnson, catherine_manson, etc.

  • @filename *= "*.mp?"

    Matches any MP3 or MP4 file name.

  • @title *= "colo*r"

    Matches titles that contain either the color or the colour spelling.

Fuzzy match

Fuzzy matches broaden the search results by allowing for some variance between the query string and the matched results. The fuzzy match operator (~=) applies to a minimum of 2 words and searches for matches that vary by up to 20% from the queried value (that is, the matches can be up to 20% longer or shorter, can contain up to 20% different characters, or any combination thereof).

  • @country ~= "United Sttes"

    The correct spelling of United States is one character longer than the queried value. The correctly spelled country will be returned as a match because it only varies from the query string by 8% (that is, it’s 1 character longer than the 11 characters in the query).

  • @country ~= "Untied Stets"

    The correct spelling of United States is one character longer than and differs by two characters from the queried value. The correctly spelled country won’t be returned as a match because it varies from the query string by 23%.

Using a wildcard in a fuzzy match

You can only add a wildcard (*) to the end of a fuzzy query. If the * character appears anywhere else, it isn’t interpreted as a wildcard.

  • @author ~= "Dipartiment of*"

    The queried value (not including the wildcard character) is 13 characters long, so matches can vary by up to 2 characters. As with any other wildcard match, all possible combinations that match the wildcard will be returned, regardless of length. In this case, for example, Department of Justice, Department of Defense, and Department of Education would all be matching values.

Phonetic match

The phonetic match operator (%=) converts the queried value to phonetic codes, compares these codes to the phonetic codes of all possible field values, and returns those that share some of the same phonetic codes.

Phonetic match can be used to find variants of people’s names.

@author %= "Georg"

Value Phonetic codes Matches
Georg JRK and KRK George and Jörg
George JRJ and KRK Georg
Jörg JRK and ARK Georg

Phonetic match looks for the phonetic codes for several languages with a limited phonetic code complexity. Consequently, the matching results may appear incomplete, particularly for long queried values.

Regular expression match

The regular expression (regex) operator (/=) applies the regular expression entered as the field value to match precise content. The regex uses a match operation to match the entire content of the field.

Use the ECMAScript regular expression syntax implemented by JavaScript.

Matches user names that are in email form.

@username /= "[\w\.%\+]+@[a-zA-Z0-9\.\-]+\.[A-Za-z]{2,4}"