Share via


NEAR Term in Enterprise Search SQL Syntax

Specifies that two content search terms must be located relatively close to one another to be recognized as matching by the CONTAINS predicate.

<content_search_term> NEAR | ~ <content_search_term>

Remarks

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

When the words in the query joined by NEAR are found within approximately 50 words of one another in the column that is 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 can be less than 50. 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.

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.

…WHERE CONTAINS('computer

NEAR software)'

Phrase

Multiple words or included spaces.

…WHERE CONTAINS('"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 in Enterprise Search SQL Syntax.

…WHERE CONTAINS('"compu*" NEAR "soft*"')

Examples

The following example shows how you can chain NEAR terms, using both the short and long forms of the term.

…WHERE CONTAINS('computer NEAR software ~ "setup application"')

See Also

Reference

CONTAINS Predicate in Enterprise Search SQL Syntax
Using Wildcards in the CONTAINS Predicate in Enterprise Search SQL Syntax