# Using Query Expressions

When you search a Verity collection, you use the CFSEARCH tag in a ColdFusion application page. Use the CRITERIA attribute to specify the query expression you want to pass to the search engine.

You can build two types of query expressions: simple and explicit. A simple query expression is typically a word or words. An explicit query expression can employ a number of operators and modifiers to refine the search. Although an explicit query can employ operators and modifiers, all aspects of the search must be explicitly invoked. A simple query expression is somewhat more powerful since it employs operators by default. You can assemble an explicit query expression programmatically or simply pass a simple query expression to the search engine directly from an HTML input form.

The Verity query language provides many operators and modifiers for composing queries. The following search techniques can be used in searching a Verity collection:

- Word searches
- Proximity searches
- Concept-based
- Field searches in which documents are match based on matching predefined custom attributes
- Scoring operators

## Simple query expressions

Simple queries allow end users to enter simple, comma-delimited strings and use wildcard characters. You can enter multiple words separated by commas, in which case the comma is treated like a logical OR. If you omit the commas, the query expression is treated as a phrase.

Ordinarily, operators are employed in explicit query expressions. Operators are normally surrounded by angle brackets < >. However, you can use the AND, OR, and NOT operators in a simple query without using angle brackets.

A simple query employs the STEM operator and the MANY modifier. STEM searches for words that derive from those entered in the query expression, so that entering "find" will return documents that contain "find," "finding," "finds," etc. The MANY modifier forces the documents returned in the search to be presented in a list based on a relevancy score.

## Explicit query expressions

Explicit queries can be constructed using a variety of operators, which are described below. Most operators in an explicit query expression are surrounded by angle brackets < >. You can use the AND, OR, and NOT operators without angle brackets.

## Expression syntax

You can use either simple or explicit syntax when stating simple query syntax. The syntax you use determines whether the search words you enter will be stemmed, and whether the words that are found will contribute to relevance-ranked scoring.

### Simple syntax

When you use simple syntax, the search engine implicitly interprets single words as if they were modified by the MANY and STEM operators. By implicitly applying the MANY modifier, the search engine calculates each document's score based on the density of the search term in the searched documents. The more frequent the occurrence of a word in a document, the higher the document's score.

As a result, the search engine ranks documents according to word density as it searches for the word you specify, as well as words that have the same stem. For example, "films," "filmed," and "filming" are stemmed variations of the word "film." To search for documents containing the word "film" and its stem words, you can enter the word "film" without modification. When documents are ranked by relevance, they appear in a list with the most relevant documents at the top.

### Explicit syntax

When you use explicit syntax, the search engine interprets the search terms you enter as literals. For example, by entering the word "film" (including quotation marks) using explicit syntax, the stemmed versions of the word "film", "films," "filmed," and "filming" are ignored.

The following table shows all operators available for conducting searches of ColdFusion Verity collections.

Verity Search Operators
< | CONTAINS | PHRASE
<= | ENDS | SENTENCE
= | MATCHES | STARTS
> | NEAR | STEM
>= | NEAR/N | SUBSTRING
Accrue | OR | WILDCARD
AND | PARAGRAPH | WORD

## Special characters

A number of characters are handled in particular ways by the search engine.

Special Search Characters
Characters | Description
--- | ---
, () [ | These characters end a text token.
= > <! | These characters also end a text token. They are terminated by an associated end character.
' @ ` < {[! | These characters signify the start of a delimited token. They are terminated by an associated end character.

A backslash (\) removes special meaning from whatever character follows it. To enter a literal backslash in a query, use two in succession, such as this examples:

    <FREETEXT>("\"Hello\", said Packard.")
    "backslash (\\)"