CentOS 8
Sponsored Link

SQL Server 2019 : Full-Text Search2020/01/16

 
Install SQL Server Full-Text Search to enable Full-Text Search on tables.
[1] Install SQL Server Full-Text Search. (from MS SQL 2019 repo)
[root@dlp ~]#
dnf -y install mssql-server-fts
[root@dlp ~]#
systemctl restart mssql-server

[2] Test to run Full-Text Search.
[root@dlp ~]#
sqlcmd -S localhost -U SA

Password:

# connect to test database
1> use SampleDB;
2> go
Changed database context to 'SampleDB'.

# this is the sample table for test
1> select * from dbo.Sample_Table; 
2> go
Number     First_Name    Last_Name      Description
---------- ------------- -------------- --------------------------------------------------
00001      CentOS        Linux          This is the Community Enterprise Operating System.
00002      RedHat        Linux          RedHat Enterprise Linux.
00003      Debian        Linux          Debian GNU Linux.
00004      Ubuntu        Linux          Ubuntu is based on the Debian architecture.
00005      Windows       Microsoft      Microsoft Windows

(5 rows affected)

# create fulltext catalog named [Sample_TBCat]
1> create fulltext catalog Sample_TBCat;
2> go

# create unique index to [Number] column named [UIDoc]
1> create unique index UIDoc on Sample_Table(Number);
2> go

# create fulltext index on [Sample_TBCat] catalog
1> create fulltext index on Sample_Table(First_Name,Description)
2> key index UIDoc on Sample_TBCat;
3> go


# test to run full-text search
1> select * from dbo.Sample_Table where contains((First_Name,Description),'Enterprise');
2> go
Number     First_Name     Last_Name    Description
---------- -------------- ------------ --------------------------------------------------
00001      CentOS         Linux        This is the Community Enterprise Operating System.
00002      RedHat         Linux        RedHat Enterprise Linux.

(2 rows affected)

# test to run full-text search
1> select * from dbo.Sample_Table where freetext((Description),'GNU or architecture');
2> go
Number     First_Name   Last_Name     Description
---------- ------------ ------------- --------------------------------------------------
00003      Debian       Linux         Debian GNU Linux.
00004      Ubuntu       Linux         Ubuntu is based on the Debian architecture.

(2 rows affected)
Matched Content