andnotkey (index exclusion operator)

The andnotkey operator locates documents that contain the first specified value only, in two or more indexes.

The andnotkey operator is specified with the <andnotkey> element. The <andnotkey> element has two children. In the simplest case, each child specifies an index and a search value for that index. As usual, the type of the value (i.e., word, string, date, time or number) must match the type of the index.

For a document to be retrieved by andnotkey:

  • In the first child: The search value for the index must be found in the document, AND
  • In the second child: The search value for the index must NOT be found in the document.

The following sample query will retrieve all news stories dated July 2000, with the exception of stories that have Canada in the headline.

<?xml version="1.0" encoding="UTF-16"?>
<!-- andnotkeyQuery.xml -->
<query VERSION="4.5" RESULTSPACE="andnotkeyQuery"> 
    <andnotkey> 
        <key NAME="Date"> 
            <date>
                <year>2000</year>
                <month>07></month>
            </date>
        </key> 
        <key NAME="Headline"> 
            <elem>Canada</elem> 
        </key> 
     </andnotkey> 
</query>