Oracle8i interMedia Text Reference
Release 2 (8.1.6)

Part Number A77063-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Query Operators, 2 of 26


Operator Precedence

Operator precedence determines the order in which the components of a query expression are evaluated. Text query operators can be divided into two sets of operators that have their own order of evaluation. These two groups are described below as Group 1 and Group 2.

In all cases, query expressions are evaluated in order from left to right according to the precedence of their operators. Operators with higher precedence are applied first. Operators of equal precedence are applied in order of their appearance in the expression from left to right.

Group 1 Operators

Within query expressions, the Group 1 operators have the following order of evaluation from highest precedence to lowest:

  1. EQUIValence (=)

  2. NEAR (;)

  3. weight (*), threshold (>)

  4. MINUS (-)

  5. NOT (~)

  6. WITHIN

  7. AND (&)

  8. OR (|)

  9. ACCUMulate ( , )

Group 2 Operators and Characters

Within query expressions, the Group 2 operators have the following order of evaluation from highest to lowest:

  1. Wildcard Characters

  2. ABOUT

  3. stem ($)

  4. fuzzy (?)

  5. soundex (!)

Procedural Operators

Other operators not listed under Group 1 or Group 2 are procedural. These operators have no sense of precedence attached to them. They include the SQE and thesaurus operators.

Precedence Examples

Query Expression  Order of Evaluation 

w1 | w2 & w3 

(w1) | (w2 & w3) 

w1 & w2 | w3 

(w1 & w2) | w3 

?w1, w2 | w3 & w4 

(?w1), (w2 | (w3 & w4)) 

abc = def ghi & jkl = mno 

((abc = def) ghi) & (jkl=mno) 

dog and cat WITHIN body 

dog and (cat WITHIN body)  

In the first example, because AND has a higher precedence than OR, the query returns all documents that contain w1 and all documents that contain both w2 and w3.

In the second example, the query returns all documents that contain both w1 and w2 and all documents that contain w3.

In the third example, the fuzzy operator is first applied to w1, then the AND operator is applied to arguments w3 and w4, then the OR operator is applied to term w2 and the results of the AND operation, and finally, the score from the fuzzy operation on w1 is added to the score from the OR operation.

The fourth example shows that the equivalence operator has higher precedence than the AND operator.

The fifth example shows that the AND operator has lower precedence than the WITHIN operator.

Altering Precedence

Precedence is altered by grouping characters as follows:


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index