Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is proximity term query supported by CONTAINS

Author  Topic 

ozSQLServer
Starting Member

32 Posts

Posted - 2011-12-04 : 19:59:59
Hi,

In full-text indexing, the following link states that "proximity term" query is supported only by CONTAINSTABLE function:
[url]http://msdn.microsoft.com/en-us/library/cc879300.aspx[/url]

However, when I tested it with CONTAINS predicate, it works just the same:

USE Northwind;
GO

SELECT CategoryID, CategoryName, Description
FROM Categories
WHERE CONTAINS (Description, '(fruit NEAR bean)');


Can I really use CONTAINS predicate for proximity term query in Full-Text searching?

Thanks

Cheers,
ozSQL

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-05 : 00:02:08
its also specified for CONTAINS.
This is from BOL


<proximity_term>
Specifies a match of words or phrases that must be in the document that is being searched. Like the AND operator, <proximity_term> requires both the search terms to exist in the document being searched.

NEAR | ~
Indicates that the word or phrase on each side of the NEAR or ~ operator must occur in a document for a match to be returned. Several proximity terms can be chained, as in a NEAR b NEAR c or a ~ b ~ c. Chained proximity terms must all be in the document for a match to be returned.

When used in the CONTAINSTABLE function, the proximity of the search terms affects the ranking of each document. The nearer the matched search terms are in a document, the higher the ranking of the document. If matched search terms are >50 terms apart, the rank returned on the document is 0.

For example, CONTAINS (column_name, 'fox NEAR chicken') and CONTAINSTABLE (table_name, column_name, 'fox ~ chicken') would both return any documents in the specified column that contain both "fox" and "chicken". In addition, CONTAINSTABLE returns a rank for each document based on the proximity of "fox" and "chicken". For example, if a document contains the sentence, "The fox ate the chicken," its ranking would be high.

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.




for full explanation see
http://msdn.microsoft.com/en-us/library/ms187787.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -