images/contents.gifimages/index.gif

Advanced Search Concepts and Complex Queries

When any query is evaluated, each search keyword in the query is used to derive a list of all news headlines which contain a matching indexed keyword. Every such list is known as a match-list. As seen already, a simple query is comprised of only a single search keyword; therefore, the result of a simple query is nothing more than the match-list derived from the given search keyword.

A complex query, however, contains two or more search keywords joined by special characters known as query operators, or operators. When multiple search keywords are given, an equal number of match-lists will be derived during evaluation of the query; query operators are necessary to govern how all of the match-lists should be combined to eventually form only a single match-list as the result of the query.

When building and working with queries, however, it is more convenient to think in terms of an abstraction known as a query element. Match-lists are circumstantial, derivative values whereas query elements are a fundamental unit of a querys structure. All queries are built out of query elements and query operators; query elements describe the keyword qualifications from which match-lists are derived, and query operators describe the relationships between query elements.

We define a query element to be either simple or compound. A simple query element is composed of a single search keyword specification. A compound query element contains two or more query elements joined by one or more query operators. The number of operators is always one less than the number of elements. (When three or more query elements occur in a compound query element, we refer to that element as a chained query element; such elements are discussed later.)

Note: The query elements comprising a compound query element may, in and of themselves, also be compound query elements (because any query element can be simple or compound). This gives rise to the notion of nested query elements, which is discussed later.


Every query element (simple or compound) in a search query is ultimately used to derive a single match-list of news stories when the query is evaluated. Simple query elements evaluate directly to a single match-list. For compound query elements, every query operator requires two query elements, one on either side of the operator; after the two query elements have been evaluated to produce a single match-list each, the query operator combines the two match-lists into a new, single match-list. When there are no more operators within the same compound query element, then the match-list resulting from the last-performed operation becomes the value for the entire compound query element.

In fact, a complete search query (simple or complex) is always nothing more than a solitary query element; because there is no further operation to be performed on that elements derived match-list, that match-list becomes the final result of the search query. Therefore, we can refine our definition of search queries to be the following: a simple search query is merely a solitary instance of a simple query element; and a complex search query is a solitary instance of a compound query element.

Topics:

A Complex Query Example

Chained Query Elements

Grouping and Precedence

Nested Query Elements

News Query Operators

Relative order of Query Elements