[ You are here: XTF -> Tag Reference -> crossQuery -> Query Parser Output Tags -> NOT Search Tag ]

Not Search Tag

This tag defines a search where none of the sub-terms or clauses must exist in a document for a match to be made. This tag has the form:

<not {field       = "FieldName"}
     {maxSnippets = "SnippetsToOutput"}
     {boost       = "BoostValue"}>
 
    Term | Clause
    Term | Clause
      …
</not>
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 <not> tag must match the value set in the outer tags. Otherwise, an error will be generated. However, if the <not> tag does not specify a field name, and no tags outside it specify a field name, then the tags directly below the <not> tag may have any combination of field names desired. This is how mixed queries of document text and meta data are formed.
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 <not> 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 <not> 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 <not> tag have boost attributes, their individual boost values will be multiplied by the boost set for the containing <not> tag.

Within the not tag, Term is a term tag, and Clause is a phrase, exact, and, or, orNear, near, resultData, or range tag.

The not tag is usually used to restrict the results of a larger query (such as an and, or, or near query.) To use it this way, embed the not tag within another query tag. However, not can also be used alone at the top level (just inside the <query> element), and the effect is to gather all documents that don't match the <not> specification.

It is important to note that when applied to the "text" field, the not tag in reality operates as a "not near." That is, the items to not be found are localized to other terms in the search query. Why? Consider a query for "bat" not "cave". Imagine a document where "bat man" appears in Chapter 1. Would you really want to ignore that match if the word "cave" appears in a wholly unrelated passage somewhere in Chapter 12? Probably not. Consequently, search elements specified within a <not> clause are considered relevant if they are within the same chunk as other elements in the query. For more about document chunks sizing, see textIndexer Configuration File section in the XTF Deployment Guide. By contrast, when applied to meta-data fields, the <not> clause operates as a "not anywhere", and ignores chunk sizing.