Search code examples
sql-servert-sqlfull-text-searchcontainstable

Building TSQL Full Text Search XOR


I've got a table with the following texual data:

  1. Linker been
  2. Linker pagina
  3. Rechter pagina

I'm using a CONTAINSTABLE. When I use the following full text expression "Linker*" AND "pagina*" only the second record is returned.

I've tried building an XOR by using expression ("Linker*" OR "pagina*") AND NOT ( "pagina*" AND "Linker*"), but all records are returned.

Why?


Solution

  • I have tried this

    SELECT * FROM CONTAINSTABLE(data,*,'("Linker*" OR "pagina*") AND NOT (  "pagina*" AND  "Linker*")') AS Results
    

    Returned this to me: enter image description here

    You can also try "AND NOT" the CONTAINSTABLE of the AND itself as follows:

    SELECT * FROM CONTAINSTABLE(data,*,'"Linker*" OR "pagina*"') AS Results
    WHERE Results.[KEY] NOT IN
    (SELECT [Key] FROM CONTAINSTABLE(data,*,'"Linker*" AND "pagina*"'))
    

    This is the return: enter image description here