2

I am using SQL Server 2019. I define thesaurus in language XML in SQL Server full text search.

<XML ID="Microsoft Search Thesaurus">
<thesaurus xmlns="x-schema:tsSchema.xml">
<diacritics_sensitive>0</diacritics_sensitive>
    <expansion>
        <sub>DNA typing</sub>
        <sub>genetic fingerprinting</sub>
    </expansion>
</thesaurus>
</XML>

As thesaurus and prefix form (*) can not be used inside contains statement such as

SELECT * 
FROM new_framework_text ft 
WHERE CONTAINS (ft.text, N'FORMSOF (THESAURUS,"DNA typing*")')

Usually, I use this query for get result, but it is not actually return desired result.

SELECT * 
FROM new_framework_text ft 
WHERE CONTAINS (ft.text, N'FORMSOF (THESAURUS, "DNA typing") OR "DNA typing*"')

Above, query will return rows with 'DNA typing', 'genetic fingerprinting' and 'DNA typing*'.

It can not get the rows start with thesaurus word which is 'genetic fingerprinting*'.

I do not want to write static code in project, because there will be a lot of thesaurus in future.

I searched the internet, but can not find any valid answer.

How can I achieve to get needed records with just only query?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0