0

Why we need FREETEXT if we already have CONTAINS? in SQL Server can you you give where exactly we can make use of.

Syntax for using FREETEXT is exactly the same as CONTAINS , so When you need to do an CONTAINS and FREETEXT,

Ramakrishna.p
  • 1,159
  • 12
  • 31
  • [`FREETEXT`](https://learn.microsoft.com/en-us/sql/t-sql/queries/freetext-transact-sql?view=sql-server-ver15), [`CONTAINS`](https://learn.microsoft.com/en-us/sql/t-sql/queries/contains-transact-sql?view=sql-server-ver15). It's fairly clear what's different about them from their descriptions...? – T.J. Crowder Dec 23 '20 at 10:30
  • Syntax can be the same for many functions, doesn't mean that they do the same thing. `ASCII('1')` and `CHAR('1')` would return very different results, but the syntax is the same. – Thom A Dec 23 '20 at 10:33
  • Possible [dba.se] duplicate: [Is it better to use FREETEXT or CONTAINS Full Text Searches when searching by single characters](https://dba.stackexchange.com/q/6766/140734) – Thom A Dec 23 '20 at 10:34

1 Answers1

1

FREETEXT evaluates not only on the string, but also the meaning. Whereas CONTAINS is used for precise or fuzzy searching on a string.

CONTAINS and FREETEXT are quite similar functions. Both return a boolean value, and both take 2 parameters: a Free-Text indexed column name and the Free-Text search term. But they behave quite differently.

Like larnu said, even sometimes the syntax can be the same, it doesn't mean the do the same thing.

FREETEXT is more restrictive predicate which by default does a search based on various forms of a word or phrase (that means it by default includes Inflectional forms as well as thesaurus).

CONTAINS, unlike FREETEXT, gives you flexibility to do various forms of search separately.

Here are the blogs which showed us some examples to make it more clear how different searches are done through FREETEXT and CONTAINS. This may help you have a good understand about FREETEXT and CONTAINS.

Ref:

  1. Is it better to use FREETEXT or CONTAINS Full Text Searches when searching by single characters
  2. Full Text Queries : CONTAINS and FREETEXT predicates
  3. Sql Server Full-Text Search Protips Part 2: CONTAINS vs. FREETEXT

HTH.

Leon Yue
  • 15,693
  • 1
  • 11
  • 23