Elements of Query Expressions


A query expression is any statement you enter as criteria for performing a search. The words and operators you use in a query expression comprise its elements.

When the simple query parser (the default parser) is used, you can state a query expression using simple or explicit 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 you enter as if they were preceded by the MANY modifier and the STEM operator. By implicitly applying the MANY modifier, the search engine calculates each document's score based on the word density it finds; the denser the occurrence of a word in a document, the higher the document's score.

As a result, the search engine relevance-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" using simple syntax:

film

When documents are relevance-ranked, they are listed in an order based on their relevance to your search criteria. Relevance-ranked results are presented with the most relevant documents at the top of the list.

Left and right angle brackets (< >) are reserved for designating operators and modifiers. They are optional for AND, OR, and NOT, but required in all other cases.

To include a backslash (\) in a search, insert two backslashes for each backslash character. To search for "C:\bin\print," you can enter the following simple syntax:

C:\\bin\\print

For simple queries, you can simply enter the topic name as you would a word or phrase.

The search engine also interprets words that are topic names as topics rather than as individual words when you use simple syntax. This means that if the text you enter contains a topic name, the query corresponding to that topic is used instead of the word itself.

Explicit Syntax

When you enclose individual words in double quotation marks, the Verity search engine interprets those words literally. For example, by entering the word "film" explicitly in double-quotation marks, the words "films," "filmed," and filming" will not be considered in the search. To select documents containing the word "film" without searching for its stemmed words, you can enter the word "film" using explicit syntax:

"film"

The following example retrieves documents that contain both the literal phrase "pharmaceutical companies" and the literal word "stock":

AND ("pharmaceutical companies", "stock")

The AND operator does not require angle brackets, because it is automatically interpreted as an operator.

The following example retrieves documents containing the phrase "black and white":

<PHRASE> (black "and" white)

The PHRASE operator does require angle brackets, and the "and" is enclosed in double quotation marks because it is to be interpreted as a literal word, not as an operator.

Additionally, when you enter a topic name enclosed in double quotation marks, the search engine will interpret the topic name as a literal word instead of as a topic. This is useful if you want to search for a word that is the same as the name of a topic.

Syntax Options

Following is a summary of Verity query language syntax options, including alternative syntax and topics, that you can use to compose query expressions.

Using Shorthand Notation

The Verity query language provides a few alternatives you can use to specify evidence operators. In the examples below, "word" represents the word to be located.

Standard Query Expression
Equivalent Format
<MANY><WORD>word
"word"


<MANY><STEM>word
'word'


Specifying Topic Names

You can specify topics in expressions in a variety of ways. Use any of the following formats to specify a topic explicitly in an expression:

{topic_name}

<TOPIC>topic_name

<TOPIC>(topic_name)

{KB:topic_name}

In the examples above, topic_name represents the name of the topic to be used in the expression. KB represents the name of the knowledge base to be used in the expression.

Precedence Evaluation

Precedence rules and syntax affect the evaluation of queries, as described below.

Precedence Rules

A Verity query expression is read using explicit precedence rules applying to the operators which are used. While a query expression is read from left to right, some operators carry more weight than others and this will affect the interpretation of the expression. For example, an AND operator takes precedence over an OR operator. For this reason, the following example is interpreted to mean: Look for documents that contain b and c, or documents that contain a.

a OR b AND c

To ensure that the OR operator is interpreted first, you can use parentheses as follows:

(a OR b) AND c

In general, the appropriate use of parentheses in query expressions, especially complex ones, will ensure that the query expression is interpreted as intended.

Parentheses in Expressions

Parentheses indicate the order the directions are to be carried out; information within parentheses is read first, then information outside parentheses is read next. Note that there must be at least one space between operators and words used in the expression. The following example means: Look for documents that contain a and b, or documents that contain c.

(a AND b) OR c

If there are nested parentheses, start with the innermost level. The following example means: Look for documents that contain b or c as well as a, or that contain d.

(a AND (b OR c)) OR d





Copyright © 1998, Verity, Inc. All rights reserved.