PK
)Aoa, mimetypeapplication/epub+zipPK )A iTunesMetadata.plist;
This chapter describes operator precedence and provides descriptions, syntax, and examples for every CONTAINS operator. The following topics are covered:
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 later 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.
Within query expressions, the Group 1 operators have the following order of evaluation from highest precedence to lowest:
Within query expressions, the Group 2 operators have the following order of evaluation from highest to lowest:
Wildcard Characters
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.
Table 3-1 Query Expression 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.
Precedence is altered by grouping characters as follows:
Within parentheses, expansion or execution of operations is resolved before other expansions regardless of operator precedence.
Within parentheses, precedence of operators is maintained during evaluation of expressions.
Within parentheses, expansion operators are not applied to expressions unless the operators are also within the parentheses.
General Behavior
Use the ABOUT
operator to return documents that are related to a query term or phrase. In English and French, ABOUT
enables you to query on concepts, even if a concept is not actually part of a query. For example, an ABOUT
query on heat might return documents related to temperature, even though the term temperature is not part of the query.
In other languages, using ABOUT
will often increase the number of returned documents and may improve the sorting order of results. For all languages, Oracle Text scores results for an ABOUT
query with the most relevant document receiving the highest score.
English and French Behavior
In English and French, use the ABOUT
operator to query on concepts. The system looks up concept information in the theme component of the index. Create a theme component to your index by setting the INDEX_THEMES
BASIC_LEXER attribute to YES
.
Note: You need not have a theme component in the index to enterABOUT queries in English and French. However, having a theme component in the index yields the best results for ABOUT queries. |
Oracle Text retrieves documents that contain concepts that are related to your query word or phrase. For example, if you enter an ABOUT
query on California, the system might return documents that contain the terms Los Angeles and San Francisco, which are cities in California.The document need not contain the term California to be returned in this ABOUT
query.
The word or phrase specified in your ABOUT
query need not exactly match the themes stored in the index. Oracle Text normalizes the word or phrase before performing lookup in the index.
You can use the ABOUT
operator with the CONTAINS
and CATSEARCH
SQL operators. In the case of CATSEARCH
, you must use query templating with the CONTEXT
grammar to query on the indexed themes. See ABOUT Query with CATSEARCH in the Examples section.
Syntax
Syntax | Description |
---|---|
about(phrase) | In all languages, increases the number of relevant documents returned for the same query without the ABOUT operator.The phrase parameter can be a single word or a phrase, or a string of words in free text format.
In English and French, returns documents that contain concepts related to phrase, provided the The score returned is a relevance score. Oracle Text ignores any query operators that are included in phrase. If your index contains only theme information, an The phrase you specify cannot be more than 4000 characters. |
ABOUT
queries give the best results when your query is formulated with proper case. This is because the normalization of your query is based on the knowledge catalog which is case-sensitive.
However, you need not type your query in exact case to obtain results from an ABOUT
query. The system does its best to interpret your query. For example, if you enter a query of CISCO and the system does not find this in the knowledge catalog, the system might use Cisco as a related concept for look-up.
Improving ABOUT Results
The ABOUT
operator uses the supplied knowledge base in English and French to interpret the phrase you enter. Your ABOUT
query therefore is limited to knowing and interpreting the concepts in the knowledge base.
Improve the results of your ABOUT
queries by adding your application-specific terminology to the knowledge base.
Limitations
The phrase you specify in an ABOUT
query cannot be more than 4000 characters.
Single Words
To search for documents that are about soccer, use the following syntax:
'about(soccer)'
Phrases
Further refine the query to include documents about soccer rules in international competition by entering the phrase as the query term:
'about(soccer rules in international competition)'
In this English example, Oracle Text returns all documents that have themes of soccer, rules, or international competition.
In terms of scoring, documents which have all three themes will generally score higher than documents that have only one or two of the themes.
Unstructured Phrases
You can also query on unstructured phrases, such as the following:
'about(japanese banking investments in indonesia)'
Combined Queries
Use other operators, such as AND
or NOT
, to combine ABOUT
queries with word queries. For example, enter the following combined ABOUT
and word query:
'about(dogs) and cat'
Combine an ABOUT
query with another ABOUT
query as follows:
'about(dogs) not about(labradors)'
Note: You cannot combineABOUT with the WITHIN operator, as for example 'ABOUT (xyz) WITHIN abc'. |
ABOUT Query with CATSEARCH
Enter ABOUT
queries with CATSEARCH
using the query template method with grammar set to CONTEXT
as follows:
select pk||' ==> '||text from test where catsearch(text, '<query> <textquery grammar="context"> about(California) </textquery> <score datatype="integer"/> </query>','')>0 order by pk;
Use the ACCUM
operator to search for documents that contain at least one occurrence of any query terms, with the returned documents ranked by a cumulative score based on how many query terms are found (and how frequently).
Syntax
Syntax | Description |
---|---|
term1,term2
term1 ACCUM term2 | Returns documents that contain term1 or term2. Ranks documents according to document term weight, with the highest scores assigned to documents that have the highest total term weight. |
ACCUMulate first scores documents on how many query terms a document matches. A document that matches more terms will always score higher than a document that matches fewer terms, even if the terms appear more frequently in the latter. In other words, if you search for dog ACCUM cat, you'll find that
the dog played with the cat
scores higher than
the big dog played with the little dog while a third dog ate the dog food
Scores are divided into ranges. In a two-term ACCUM
, hits that match both terms will always score between 51 and 100, whereas hits matching only one of the terms will score between 1 and 50. Likewise, for a three-term ACCUM
, a hit matching one term will score between 1 and 33; a hit matching two terms will score between 34 and 66, and a hit matching all three terms will score between 67 and 100. Within these ranges, normal scoring algorithms apply.
See Also: Appendix F, " The Oracle Text Scoring Algorithm" for more information on how scores are calculated |
You can assign different weights to different terms. For example, in a query of the form
soccer, Brazil*3
the term Brazil is weighted three times as heavily as soccer. Therefore, the document
people play soccer because soccer is challenging and fun
will score lower than
Brazil is the largest nation in South America
but both documents will rank below
soccer is the national sport of Brazil
Note that a query of soccer ACCUM Brazil*3 is equivalent to soccer ACCUM Brazil ACCUM Brazil ACCUM Brazil. Because each query term Brazil is considered independent, the entire query is scored as though it has four terms, not two, and thus has four scoring ranges. The first Brazil-and-soccer example document shown above scores in the first range (1-25), the second scores in the third range (51-75), and the third scores in the fourth range (76-100). (No document scores in the second range, because any document with Brazil in it will be considered to match at least three query terms.)
Example
set serveroutput on; DROP TABLE accumtbl; CREATE TABLE accumtbl (id NUMBER, text VARCHAR2(4000) ); INSERT INTO accumtbl VALUES ( 1, 'the little dog played with the big dog while the other dog ate the dog food'); INSERT INTO accumtbl values (2, 'the cat played with the dog'); CREATE INDEX accumtbl_idx ON accumtbl (text) indextype is ctxsys.context; PROMPT dog ACCUM cat SELECT SCORE(10) FROM accumtbl WHERE CONTAINS (text, 'dog ACCUM cat', 10) > 0; PROMPT dog*3 ACCUM cat SELECT SCORE(10) FROM accumtbl WHERE CONTAINS (text, 'dog*3 ACCUM cat', 10) > 0;
This produces the following output. Note that the document with both dog and cat scores highest.
dog ACCUM cat ID SCORE(10) ----- ---------- 1 6 2 52 dog*3 ACCUM cat ID SCORE(10) ----- ---------- 1 53 2 76
Related Topics
See also weight (*)
Use the AND
operator to search for documents that contain at least one occurrence of each of the query terms.
Syntax
Syntax | Description |
---|---|
term1&term2
term1 and term2 | Returns documents that contain term1 and term2. Returns the minimum score of its operands. All query terms must occur; lower score taken. |
Example
To obtain all the documents that contain the terms blue and black and red, enter the following query:
'blue & black & red'
In an AND
query, the score returned is the score of the lowest query term. In this example, if the three individual scores for the terms blue, black, and red is 10, 20 and 30 within a document, the document scores 10.
Related Topics
See Also: TheAND operator returns documents that contain all of the query terms, while OR operator returns documents that contain any of the query terms. See "OR (|)". |
Use the broader term operators (BT
, BTG
, BTP
, BTI
) to expand a query to include the term that has been defined in a thesaurus as the broader or higher level term for a specified term. They can also expand the query to include the broader term for the broader term and the broader term for that broader term, and so on up through the thesaurus hierarchy.
Syntax
Syntax | Description |
---|---|
BT(term[(qualifier)][,level][,thes]) | Expands a query to include the term defined in the thesaurus as a broader term for term . |
BTG(term[(qualifier)][,level][,thes]) | Expands a query to include all terms defined in the thesaurus as broader generic terms for term . |
BTP(term[(qualifier)][,level][,thes]) | Expands a query to include all the terms defined in the thesaurus as broader partitive terms for term . |
BTI(term[(qualifier)][,level][,thes]) | Expands a query to include all the terms defined in the thesaurus as broader instance terms for term . |
Specify the operand for the broader term operator. Oracle Text expands term to include the broader term entries defined for the term in the thesaurus specified by thes. For example, if you specify BTG(dog), the expansion includes only those terms that are defined as broader term generic for dog. You cannot specify expansion operators in the term
argument.
The number of broader terms included in the expansion is determined by the value for level
.
Specify a qualifier for term
, if term
is a homograph (word or phrase with multiple meanings, but the same spelling) that appears in two or more nodes in the same hierarchy branch of thes
.
If a qualifier is not specified for a homograph in a broader term query, the query expands to include the broader terms of all the homographic terms.
Specify the number of levels traversed in the thesaurus hierarchy to return the broader terms for the specified term. For example, a level of 1 in a BT query returns the broader term entry, if one exists, for the specified term. A level of 2 returns the broader term entry for the specified term, as well as the broader term entry, if one exists, for the broader term.