Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FTS query, Can you find all entries contains 'abc'

I am new to Full Text Search, how do I perform a search using Contains instead of using like in the following query

Select * From Students Where FullName LIKE '%abc%'

Thanks

like image 581
Costa Avatar asked Dec 30 '25 18:12

Costa


2 Answers

Something like:

SELECT * From Students Where CONTAINS(FullName,'abc')

Link to MSDN documentation

like image 145
Icarus Avatar answered Jan 02 '26 09:01

Icarus


Check when your catalog was last populated using this script:

DECLARE @CatalogName VARCHAR(MAX)
SET     @CatalogName = 'FTS_Demo_Catalog'

SELECT
    DATEADD(ss, FULLTEXTCATALOGPROPERTY(@CatalogName,'PopulateCompletionAge'), '1/1/1990') AS LastPopulated
    ,(SELECT CASE FULLTEXTCATALOGPROPERTY(@CatalogName,'PopulateStatus')
        WHEN 0 THEN 'Idle'
        WHEN 1 THEN 'Full Population In Progress'
        WHEN 2 THEN 'Paused'
        WHEN 3 THEN 'Throttled'
        WHEN 4 THEN 'Recovering'
        WHEN 5 THEN 'Shutdown'
        WHEN 6 THEN 'Incremental Population In Progress'
        WHEN 7 THEN 'Building Index'
        WHEN 8 THEN 'Disk Full.  Paused'
        WHEN 9 THEN 'Change Tracking' END) AS PopulateStatus
FROM sys.fulltext_catalogs AS cat

You may need to re-populate your Full Text Index in order to see current results. If you defined the FTS column, and then loaded data into the table, your search index is not up to date.

enter image description here

If you need this to be regularly updated, check out this article on Tech Net

like image 21
Tom Halladay Avatar answered Jan 02 '26 09:01

Tom Halladay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!