Oracle Text Reference Release 9.0.1 Part Number A90121-01 |
|
CONTAINS Query Operators, 10 of 28
Use this operator to do path searching in XML documents. This operator is like the WITHIN operator except that the right-hand side is a parentheses enclosed path, rather than a single section name.
Your index must be created with the PATH_SECTION_GROUP for the INPATH operator to work.
The INPATH operator has the following syntax:
Syntax | Description |
---|---|
term INPATH (A) |
Returns documents that have term within the top-level tags <A> and </A>. The A tag must be a top-level tag, which is the document-type tag. |
Syntax | Description |
---|---|
term INPATH (//A) |
Returns documents that have term in the <A> tag at any level. This query is the same as 'term WITHIN A' |
Syntax | Description |
---|---|
term INPATH (A/B) |
Returns documents where term appears in a B element which is a direct child of a top-level A element. For example, a document containing is returned. |
Syntax | Description |
---|---|
term INPATH(A//B) |
Returns documents where term appears in a B element which is some descendant (any level) of a top-level A element. |
Syntax | Description |
---|---|
term INPATH (//A/@B) |
Returns documents where term appears in the B attribute of an A element at any level. Attributes must be bound to a direct parent. |
Syntax | Description |
---|---|
term INPATH (A[B = "value"])) |
Returns documents where term appears in an A tag which has a B tag whose value is value. |
Syntax | Description |
---|---|
term INPATH (A[NOT(B)]) |
Finds documents where term appears in a top-level A element which does not have a B element as an immediate child. |
You can nest the entire INPATH expression in another INPATH expression as follows:
(dog INPATH (//A/B/C) INPATH (D)
When you do so, the two INPATH paths are completely independent. The outer INPATH path does not change the context node of the inner INPATH path. For example:
(dog INPATH (A)) INPATH (D)
never finds any documents, because the inner INPATH is looking for dog within the top-level tag A, and the outer INPATH constrains that to document with top-level tag D. A document can have only one top-level tag, so this expression never finds any documents.
Tags and attribute names in path searching are case-sensitive. That is,
dog INPATH (A)
finds <A>dog</A>
but does not find <a>dog</a>
. Instead use
dog INPATH (a)
To find all documents that contain the term dog in the top-level tag <A>:
dog INPATH (/A)
or
dog INPATH(A)
To find all documents that contain the term dog in the <A> tag at any level:
dog INPATH(//A)
This query finds the following documents:
<A>dog</A>
and
<A><B><C>dog</C></B></A>
To find all documents that contain the term dog in a B element that is a direct child of a top-level A element:
dog INPATH(A/B)
This query finds the following XML document:
<A><B>My dog is friendly.</B><A>
but does not find:
<C><B>My dog is friendly.</B></C>
You can test the value of tags. For example, the query:
dog INPATH(A[B="dog"])
Finds the following document:
<A><B>dog</B></A>
But does not find:
<A><B>My dog is friendly.</B></A>
You can search the content of attributes. For example, the query:
dog INPATH(//A/@B)
Finds the document
<C><A B="snoop dog"> </A> </C>
You can test the value of attributes. For example, the query
California INPATH (//A[@B = "home address"])
Finds the document:
<A B="home address">San Francisco, California, USA</A>
But does not find:
<A B="work address">San Francisco, California, USA</A>
You can test if a path exists with the HASPATH operator. For example, the query:
HASPATH(A/B/C)
finds and returns a score of 100 for the document
<A><B><C>dog</C></B></A>
without the query having to reference dog at all.
The following is an example of an INPATH equality test.
dog INPATH (A[@B = "foo"])
The following limitations apply for these expressions:
dog INPATH (A[@B= "pot of gold"])
matches the following sections:
<A B="POT OF GOLD">dog</A>
and
<A B="pot of gold">dog</A>
because lexer is case-insensitive by default.
<A B="POT BLACK GOLD">dog</A>
because OF is a default stopword in English and the query matches any word in that position.
<A B="POT_OF_GOLD">dog</A>
because the underscore character is not a join character by default.
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|