Share via


NEAR Term

The NEAR term is used to specify that two content search terms must be relatively close to one another to be recognized as matching for the CONTAINS predicate.

The syntax for the NEAR term is:

<content_search_term> NEAR | ~ <content_search_term>

The NEAR term can be represented by the keyword "NEAR" or by a tilde (~).

When the words joined by NEAR in the query are found within approximately 50 words of one another inside the column being searched, the NEAR term returns a match. The closer together the two words are, the higher the calculated rank for the NEAR term. The farther apart the two words are, the lower the rank.

Note  The number of words is approximate. It may be less than 50.

The following table describes content search term types that can be used with a NEAR term in a CONTAINS predicate.

Type Description Examples
Word A single word without spaces or other punctuation. Double quotation marks are not necessary.
…WHERECONTAINS('computer
NEAR software)')
Phrase Multiple words or included spaces.
…WHERECONTAINS('"computer software" NEAR hardware)')
Wildcard Words or phrases with the asterisk (*) added to the end. For more information, see Using Wildcards in the CONTAINS Predicate.
…WHERECONTAINS('"compu*" NEAR "soft*"')

Note  If the match words specified with the NEAR term are both found in the column being searched, but are farther apart than 50, the result is still returned, but has a rank of 0.

Example

The following example shows chaining of NEAR terms, using both the short and long forms of the term:

…WHERECONTAINS('computer NEAR software ~ "setup application"')

Full-Text Predicates

Using Wildcards in the CONTAINS Predicate

WHERE Clause