Within Operator
The Within operator is used to ensure that your search terms are related to each other. This is called a proximity search, an advanced search where terms can be matched (are related to each other) while avoiding search results where the terms are scattered across a file and are unrelated to each other. You can combine several Within operators in the same search query.
syntax
semantics
Recommended Use
left_query W/n right_query
where n is the maximum number of terms to look for for the left_query to the left and right of the right_query.
The left_ and right_query may not contain a NOT query (any context), TO query, Field query (IN) or Field filter query (for example, 'date=10/12/1980').
Limit your search to words that appear within a defined range in either direction.
left_query W/n/term right_query
where term can be a word (for example,
left_query /n,m/ right_query
where n is the maximum number of terms the left_query may precede the right_query, and m is the maximum number of terms the left_query may follow the right_query.
Examples
Examples Search Queries
Search Results
Search Results Explained
Tom w/2 John
'Tom
knows
John
because
Tom
went to school with John's brother.'
The term 'Tom' has token ids 1 and 5, and the term 'John' has token id 3. So, the token at position 1 is within 2 positions of the token at position 3, and so is the token at position 5.
Tom Smith w/2 John Doe
'Tom Smith
knows
John Doe
because Tom Smith went to school with John's brother.'
The term 'Smith' has token ids 2 and 8, and the term 'John' has token id 4. So, the token at position 2 is within 2 positions of the token at position 4, but the token at position 8 is not.
John Doe w/2 Tom Smith
'Tom Smith knows
John Doe
because
Tom Smith
went to school with John's brother.'
The term 'Doe' has token id 5, and the term 'Tom' has token ids 2 and 7. So, the token at position 5 is within 2 positions of the token at position 7, but not within 2 positions of the token at position 2.
Tom Smith w/3 John Doe
'Tom Smith
knows
John Doe,
Tom Smith
went to school with John's brother.'
The term 'Smith' is at positions 2 and 7, and the term 'John' is still at position 4. So, both tokens at positions 2 and 7 are within 3 positions of the token at position 4.
Minnesota W/3/EOS Maine
Minnesota appears within 3 sentences of Maine, and vice versa.
The EOS (End Of Sentence) separator is used.
John /4,10/ Tom
John appears within a maximum of 4 positions before Tom and 10 positions after Tom.
Performance Tip: Choose W/3 - W/5 to search in approximately the same phrase.
sandwich
), a number or a separator (for example, EOL (End of Line)).
Choose W/15 to search in approximately the same sentence.
Choose W/50 to search in approximately the same paragraph.
Though there is an upper boundary set to 1000, it is advised to choose a number below 100 to prevent too many search results with unrelated search terms.