4.2 Query syntax | |
A Metamorph query consists of a sequence of terms that are being searched for, and optionally within and intersects settings. The intersects setting looks like @#, as we've just discussed. The within directives are either w/ or W/ followed by a regular expression, a predefined setting, or a number. The first is the start, and the second, if specified the end (otherwise the start and end are the same). The case of the W indicates whether the expression is included in the hit. This may be useful with hit-markup and mminfo. Lower-case excludes the delimiter, upper-case includes it. The predefined settings are line, sent, para, page, all.
Phrases are searched for either by enclosing the query in double quotes, or using a hyphen instead of a space. Normally the Metamorph engine treats hyphens and spaces the same when searching. In some cases that is not desirable and you can disable the behavior with the hyphenphrase setting.
A leading ~ on a term toggles the thesaurus setting for that term. If the default is on, it disables it, and if off, it uses the thesaurus.
In addition to using the thesaurus, it is possible to specify equivalence sets directly in the query. That is done with a parenthesized comma separated list, e.g. (color,red,green,blue) and is the syntax Vortex uses to pass a multiple item list into the SQL engine. Spaces are significant, so don't include any that are not intended. Phrases are allowed, e.g. (high tech,state of the art).
In addition to the ordinary word queries there are a number of special pattern matchers that can be used. The one we have already mentioned a few times is REX. That is introduced with a / character, and is used to search for regular expressions.
The other special pattern-matchers are the numeric pattern matcher, and the approximate pattern matcher. The numeric pattern matcher finds numbers in text, whether they are spelled out, or as digits, and can find numbers within a range. It is introduced with the # character. The approximate pattern matcher looks for a pattern similar to the desired word, and can handle transposition, dropped/extra characters including spaces. It is introduced with %.
The special pattern-matchers do not make use of the index, which means the queries will be slower than keyword queries. You should take care to control where you make use of them.
Back: Metamorph Philosophy | Next: Query protection |