MDATA

Use the MDATA operator to query documents that contain MDATA sections. MDATA sections are metadata that have been added to documents to speed up mixed querying.

MDATA queries are treated exactly as literals. For example, with the query:

MDATA(price, $1.24)

the $ is not interpreted as a stem operator, nor is the . (period) transformed into whitespace. A right (close) parenthesis terminates the MDATA operator, so that MDATA values that have close parentheses cannot be searched.

Syntax

MDATA(sectionname, value)

sectionname

The name of the MDATA section(s) to search. MDATA will also search DATE or numerical equality if the sectionname parameter is mapped to a FILTER BY column of DATE or some numerical type.

value

The value of the MDATA section. For example, if an MDATA section called Booktype has been created, it might have a value of paperback.

For MDATA operator on MDATA sections that are mapped to a DATE FILTER BY column, the MDATA value must follow the Date format: YYYY-MM-DD HH24:MI:SS. Otherwise, the expected rows will not be returned. If the time component is omitted, it will default to 00:00:00, according to SQL semantics.

Example for MDATA Operator

Suppose you want to query for books written by the writer Nigella Lawson that contain the word summer. Assuming that an MDATA section called AUTHOR has been declared, you can query as follows:

SELECT id FROM idx_docs
  WHERE CONTAINS(text, 'summer AND MDATA(author, Nigella Lawson)')>0

This query will only be successful if an AUTHOR tag has the exact value Nigella Lawson (after simplified tokenization). Nigella or Ms. Nigella Lawson will not work.

Notes

MDATA query values ignore stopwords.

The MDATA operator returns an unlimited number of results or 0, depending on whether the document is a match. You can set the maximum.

The MDATA operator is not supported for CTXCAT and CTXRULE indexes. Table 3-2 shows how MDATA interacts with some other query operators:

Table 2 MDATA and Other Query Operators

Operator Example Allowed?
AND dog & MDATA(a, b) yes
OR dog | MDATA(a, b) yes
NOT dog ~ MDATA(a, b) yes
MINUS dog - MDATA(a, b) yes
ACCUM dog , MDATA(a, b) yes
PHRASE MDATA(a, b) dog no
NEAR MDATA(a, b) ; dog no
WITHIN, HASPATH, INPATH MDATA(a, b) WITHIN c no
Thesaurus MDATA(a, SYN(b)) no
expansion

MDATA(a, $b)

MDATA(a, b%)

MDATA(a, !b)

MDATA(a, ?b)

no (syntactically allowed, but the inner operator is treated as literal text)
ABOUT

ABOUT(MDATA(a,b))

MDATA(ABOUT(a))

no (syntactically allowed, but the inner operator is treated as literal text)

When MDATA sections repeat, each instance is a separate and independent value. For instance, the document

<AUTHOR>Terry Pratchett</AUTHOR><AUTHOR>Douglas Adams</AUTHOR>

can be found with any of the following queries:

MDATA(author, Terry Pratchett)
MDATA(author, Douglas Adams)
MDATA(author, Terry Pratchett) and MDATA(author, Douglas Adams)

but not any of the following:

MDATA(author, Terry Pratchett Douglas Adams)
MDATA(author, Terry Pratchett & Douglas Adams)
MDATA(author, Pratchett Douglas)

ADD_MDATA

ADD_MDATA_SECTION

See Also: Oracle Text Application Developer’s Guide for information about section searching