Session: Querying: How to Perform Proximity Search

To find words within a specific distance away use Proximity method. This method is available only from DocumentQuery level and can only be used right after Search method.

Syntax

IDocumentQuery<T> Proximity(int proximity);
Parameters
proximity int Number of words within.

Example

session
    .Advanced
    .DocumentQuery<Fox>()
    .Search(x => x.Name, "quick fox").Proximity(2)
    .ToList();
session
    .Advanced
    .AsyncDocumentQuery<Fox>()
    .Search(x => x.Name, "quick fox").Proximity(2)
    .ToListAsync();
from Foxes
where proximity(search(Name, 'quick fox'), 2)