[ You are here:
XTF ->
Tag Reference ->
crossQuery ->
Query Parser Output Tags -> AND Search Tag ]
AND Search Tag
This tag defines a search where all of the sub-terms or clauses
must exist in a document for a match to be made.
If a single field is specified (using the
field attribute), documents will match if
all of the sub-terms or clauses occur in that field. If
useProximity is "yes" (the default), then documents with terms closer together and in the right order will score higher than those in which the terms are farther apart.
If multiple fields are specified (using the
fields attribute), documents will match if
all of the search terms occurs in
any of the listed fields. That is, that is, it doesn't matter which field(s) they appear in, as long as all of them appear somewhere. If in one document multiple terms appear in the same field, the score will be higher, and if the terms are close together, the score will be higher still.
This tag has the form:
<and {field = "FieldName" |
fields = "Field1,Field2,..."}
{maxSnippets = "SnippetsToOutput"}
{boost = "BoostValue"}
{useProximity = "YesOrNo"}>
Term | Clause
Term | Clause
…
{OptionalSectionTypeQuery}
</and>
where
field="FieldName" |
is an optional attribute that identifies which field in the index to search. Often 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 <and> tag must match the value set in the outer tags. Otherwise, an error will be generated. However, if the <and> tag does not specify a field name, and no tags outside it specify a field name, then the tags directly below the <and> 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 <and> 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 <and> 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 <and> tag have boost attributes, their individual boost values will be multiplied by the boost set for the containing <and> tag. |
useProxmity="YesOrNo" |
is an optional attribute that specifies whether the AND query should take the proximity of terms into account. Generally it's best to leave this on (the default) as it results in higher quality results for the user. However, turning it off can increase query processing speed, as the Text Engine will have less work to do to calculate which documents match the query. If not specified, this attribute defaults to Yes, that is, proximity will be taken into account. Note that if proximity processing is turned off, individual text hits within document text and meta-data fields will not be highlighted, and scores for matching documents will be somewhat different. |
Within the
<and> 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 query to particular sections of a document based on section types added by the
Pre-Filter stylesheet at index time.