17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11: FileTableListing 11-29 shows how to create a full-text catalog in the database and a full-text indexon the name and file_stream columns <strong>of</strong> the Documents FileTable.-- Create a full-text catalogCREATE FULLTEXT CATALOG NorthPole_Catalog AS DEFAULT-- Create a full-text index on the FileTableCREATE FULLTEXT INDEX ON Documents(name LANGUAGE 1033,file_stream TYPE COLUMN file_type LANGUAGE 1033)KEY INDEX PK__Document__5A5B77D57DF9CB0AON NorthPole_CatalogListing 11-29: Create a full-text catalog and full-text index.Now we can query the full-text catalog for a list <strong>of</strong> files that contain the text test in thefile_stream field (Listing 11-30). <strong>The</strong> FREETEXT() function is used to specify whichcolumn we are querying and the value we are looking for.SELECT file_stream.GetFileNamespacePath(1)FROM dbo.DocumentsWHERE FREETEXT(file_stream, 'test')Listing 11-30: Query a full-text catalog.Just like with any full-text index, each indexed column has a specific language codeassociated with it (the sys.fulltext_languages catalog view returns a list <strong>of</strong>supported languages and their code). If your system has documents stored in differentlanguages and you want those to be indexed correctly, you will need to create a separateFileTable for each language.A more detailed discussion <strong>of</strong> full-text search, including the predicates that can be usedand tips on maintaining the index and configuring IFilters for different file types isbeyond the scope <strong>of</strong> this book.431

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!