adj (adjacency operator)

The adj operator is used to retrieve documents that contain two words appearing in a specified order and within a specified distance from each other.

The adj operator is specified with the <adj> element. The VALUE attribute lets you specify the maximum distance, in number of words, between the search words. The order of the search words is determined by the order they are specified within the <adj> element.

This sample query retrieves documents that contain the words children and toys if the words appear in that order, and if the two words are separated by at most 5 words. For example, it would retrieve a document containing the sentence "Children need good toys".

<?xml version="1.0" encoding="UTF-16"?>
<!-- adjQuery.xml -->
<query VERSION="4.5" RESULTSPACE="adjQuery">
    <key NAME="FullText">
        <adj VALUE="5">
            <elem>children</elem>
            <elem>toys</elem>
        </adj>
    </key>
</query>
The adj operator differs from the near operator in that the words must appear in the specified order. Thus, in the example above, a document containing the sentence "Children need good toys" would be retrieved, whereas a document containing "Give toys to children" would not, since the search words do not appear in the specified order.