Advanced Field Queries
The advanced field query syntax is:
@fieldname [Advanced_field_operator] "value"
where spaces on each side of the operator are optional.
Advanced field operator | Description |
---|---|
*= | Wildcard Match |
~= | Fuzzy Match |
%= | Phonetic Match |
/= | Regular Expression Match |
The advanced field queries perform the match directly on the field values, not through the index like it is the case for normal field queries (see Field Queries). Consequently, one interesting advantage of advanced field queries is that you can search in field values for occurrences of special characters that are normally not searchable because they are not indexed and can act as search prefix or operators (see Using Special Characters in Queries and Search Prefixes and Operators).
Example: With advanced field queries you can search in field values for strings that includes dots, dashes, slashes, parenthesis, brackets, currency symbol, etc.
Requirements
-
The advanced field queries require that the queried field is a facet field (see Adding a Facet Field).
-
The field value must be enclosed in double quotes.
Notes:
-
CES 7.0.6196+ (November 2013) The syntax for wildcard, fuzzy, phonetic, and regular expression advanced field queries is supported.
-
Search results for advanced field queries will typically be returned well within 1 second, like normal queries. They can however take more time when the number of documents, the number of possible field values, and the complexity of the matching expression (particularly for regular expressions) increase, or when field values are not loaded in cache memory.
-
The wildcard, fuzzy, phonetic, and regular expression advanced field queries are case-insensitive and not subject to stemming (see About Stemming).
Wildcard Match
The wildcard advanced field operator (*=) interprets wildcard characters (?,*) present in the value without the restrictions that are normally applied when you use wildcard characters in a query that applies to the whole index (see Using Wildcards in Queries and Requirements). You can therefore use as many occurrences of wildcard characters anywhere in the value and all possible combinations will be matched.
Wildcard Field query
The wildcard matches are useful to broaden search results with variability in specific query string locations.
Examples:
-
@author *= "*smith"
You can have a wildcard character at the beginning of the value, that would match any first name or first name abbreviation.
-
@filename *= "*.mp?"
Matches any MP3 or MP4 file names.
-
@title *= "colo*r"
Matches titles with both color and colour spellings.
Fuzzy Match
The fuzzy match advanced field operator (~=) looks for values that are approximately the same as the queried value by allowing a reasonable sample (approximately 20%) of the queried characters to be different, missing, or added (see Requirements).
Examples:
-
@syslanguage ~= "lituanian"
The queried value contains 9 characters, so only 1 character can be different, missing, or added in matching values. This matches the correct language name spelling lithuanian that contains one more character.
-
@syslanguage ~= "lituanien"
This queried value still contains 9 characters, but 2 errors relative to the correctly spelled language name, so lithuanian is not matched.
You can also add the wildcard * character at the end of the queried value to apply the fuzzy match only to the start of the possible values, allowing for anything else after. However, the * character appearing anywhere else is not interpreted as a wildcard.
Example:
-
@sysauthor ~= "Dipartiment*"
The queried value has 11 characters so up to 2 characters can be different, missing, or added in the first 11 characters of matching values, so Department of Justice or Department of Defense are matching values.
Note: Your Coveo administrator can enable the use of fuzzy or phonetic search in the Coveo .NET Front-End People search interface (see Enabling Fuzzy or Phonetic Search in the People Search Interface).
Phonetic Match
The phonetic match advanced field operator (%=) looks for values that sound similar to the queried values see Requirements). Technically, a phonetic match query converts the queried value to phonetic codes, compares them with the phonetic codes of all possible field values, and returns those that share some phonetic codes.
Example: The phonetic match can be useful to find people name variants possibly from various cultures.
@sysauthor %= "Georg"
Value | Phonetic codes | Matches |
---|---|---|
Georg | JRK and KRK | George and Jörg |
George | JRJ and KRK | Georg |
Jörg | JRK and ARK | Georg |
Note: The phonetic match tries to obtain the phonetic codes for several languages with a limited phonetic code complexity. Consequently, the matching results may sometimes appear incomplete, particularly for long queried values.
Regular Expression Match
The regular expression (regex) advanced field operator (/=) applies the regular expression entered as the field value to match precise content (see Regular expression and Requirements). The regex uses a match operation (not the search operation) to match the entire content of the field.
Examples: You can use the regular expression advanced field operator to:
-
Match user name field values that are in an email form:
@username /= "[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"
-
Match document title field values that contain a specific string such as create:
@systitle /= ".*create.*"
Note: Use the ECMAScript regular expression syntax implemented for example by JavaScript (see Using Regular Expressions with JavaScript).