views:

101

answers:

2

This may sound a dumb question, can someone confirm that within a Free Text search that the query Word1 NEAR Word2 IS identical to Word2 NEAR Word1 ??

So that Word order is not relevant.

I am trying to hit highlight the results and if this is the case I need to look for occurrences of the reversal of the original search term words.

+1  A: 

I've done a quick test on a database I have with a free-text index and the results of the query don't appear to vary depending on the order of words in the NEAR query. In other words the following two queries returned the exact same results in the same order:

SELECT * FROM DOCUMENT WHERE CONTAINS (Contents, 'health NEAR medical')

SELECT * FROM DOCUMENT WHERE CONTAINS (Contents, 'medical NEAR health')

So I would conclude there is no difference. This is backed up by the documentation that states:

"NEAR indicates the logical distance between terms, rather than the absolute distance between them. For example, terms within different phrases or sentences within a paragraph are treated as farther apart than terms in the same phrase or sentence, regardless of their actual proximity, on the assumption that they are less related. Likewise, terms in different paragraphs are treated as being even farther apart."

Given that distance between two words will always be the same, regardless of order, then I can't see it would make any difference and my tests back this up.

Dan Diplo
A: 

It seems obvious when written out - thanks for running the test.

As far as I can tell, the only measure of the "nearness" of the 2 words is that the FTS rank value of 1 equates to a 50-word difference.

One assumes that a rank of 100 indicates there is no word gap, i.e. the words are consecutive.

Roger Maynard