[ You are here:
XTF ->
Tag Reference ->
crossQuery ->
Query Parser Output Tags -> OR Search Tag ]
OR Search Tag
This tag defines a search where any one of the sub-terms or clauses must exist in a document for a match to be made. This tag has the form:
<or {field = "FieldName" |
fields = "Field1,Field2,..."}
{maxSnippets = "SnippetsToOutput"}
{boost = "BoostValue"}>
Term | Clause
Term | Clause
…
{OptionalSectionTypeQuery}
</or>
where
field="FieldName" |
is an optional attribute that identifies which field in the index to search. Normally, this attribute is set to text to indicate that the main text of the document should be searched. It can also be set to the name of a meta field such as author or subject. It should be mentioned that if the field attribute appears in any tags outside it, the field name in the <or> tag must match the value set in the outer tags. Otherwise, an error will be generated. However, if the <or> tag does not specify a field name, and no tags outside it specify a field name, then the tags directly below the <or> tag may have any combination of field names desired. This is how mixed queries of document text and meta data are formed. |
fields="Field1,Field2,..." |
is a multi-field alternative to the field attribute. It identifies a list of fields in the index to search, instead of a single field. Using a list of fields is an ideal way to perform a "keyword" search, for example searching the title, subject, author, and full text of documents. It should be mentioned that the fields attribute is only applicable to <and> and <or> queries. As with the field attribute, any elements nested within the tag are not allowed to specify a field or fields. |
maxSnippets="SnippetsToOutput" |
is an optional attribute that identifies the number of snippets to pass on to the Result Formatter stylesheet for display. A snippet is defined as the matching text found in a document for a particular query, along with some additional text around it for context. The amount of context displayed for each match is defined by the maxContext attribute. If not specified this attribute defaults to 3, meaning snippets for the top three matches for a document are returned. Also, this attribute can be set to -1, meaning all the snippets for a document are returned. As with the field attribute, if the maxSnippets attribute appears in any containing tags, the value set for it in the <or> tag must match the value set in the containing tags. Otherwise, an error will be generated. Similarly, any occurrences of the maxSnippets attribute in tags within the <or> tag must have the same value as their containing tags. (Note: Allowing nested copies of the maxSnippets attribute doesn't serve a purpose other than to make it easier to write docReqParser.xsl stylesheets in a uniform way. Effectively, the outermost maxSnippets value is always used.) |
boost="BoostValue" |
is an optional attribute that specifies a relevance boost multiplier for this clause in the query. Boost values higher than 1.0 increase the relevance of a clause, while boost values between 0.0 and 1.0 decrease the relevance of a clause. Boost values less than zero will generate an error. Note that boost values multiply. That is, if tags within an <or> tag have boost attributes, their individual boost values will be multiplied by the boost set for the containing <or> tag. |
If a single field is specified (using the
field attribute), documents will match if
any search term occurs in that field. Documents with more matching terms will score and rank higher than those with fewer matching terms.
If multiple fields are specified (using the
fields attribute), documents will match if
any search term occurs in
any of the listed fields. Documents with more matching terms (in any field) will score and rank higher than those with fewer matching terms.
Within the or tag, Term is a
term tag, and Clause is a
phrase,
exact,
and,
or,
orNear,
near,
range,
resultData, or
not tag. If the field is "text", a
Section Type sub-query may optionally appear, restricting this phrase query to particular sections of a document based on section types added by the
Pre-Filter stylesheet at index time.