Tuesday, 25 November 2014

Free text search in sql

Free text search in sql


FreeText:
  • Separates the string into individual words based on word boundaries (word-breaking).
  • Generates inflectional forms of the words (stemming).
  • Identifies a list of expansions or replacements for the terms based on matches in the thesaurus.
Syntax:
FREETEXT ( { column_name | (column_list) | * } 
          , 'freetext_string' [ , LANGUAGE language_term ] )

Example:
The following example searches for all column2 values containing the words related to Test, Data, New.
SELECT Column1
FROM Table
WHERE FREETEXT (Column2, 'New Test Data' );

Use with variable:
DECLARE @SearchWord nvarchar(300);
SET @SearchWord = N'New Test Data';
SELECT Column1
FROM Table
WHERE FREETEXT(Column2, @SearchWord);

No comments:

Post a Comment