We have :
- A SQL table with records corresponding to files
- The files stored in a folder of the filesystem
The table contains information about the files like :
To search in the files, the system needs to use the information stored in the table and the files content. The system returns only the files containing the keyword searched for but the files are also filtered depending of the information stored in the table. (Only the valid documents in a selected language).
In the past, for multiple customers, index server (after renamed indexing service) was used to index the file contents.
In MSSQL server, it’s possible to query the index server in a SQL query with those concepts :
- Linked servers (to create a link between SQL server and Index server)
- Openquery (to query the index server catalog)
All the search are done using stored procedures combining all those elements.
I propose to work with the Full text search functionality proposed by SQL server. A constraint of this system is that all the files must be stored in the database. But in the last versions of SQL server, it’s possible to store only a link to the file stored in the filesystem. This solution avoids a too big database.
How to put this solution in place?
- Activate the Full text search
- Enabling FILESTREAM on an existing instance
- Enabling FILESTREAM on an existing database
- For each table:
- Enabling FILESTREAM on an existing table
- Creating a full text index on the new column
- Populating the new columns
- Updating the SP