Let's say we have an Employees
table with a full text index on a Note
field.
We can search that table using a query like this: SELECT ID FROM Employees WHERE CONTAINS(Note, 'scout')
However, if we create an EmployeesView
with something as simple as SELECT ID, Note FROM Employees
, we're not able to query that view with SELECT ID FROM EmployeesView WHERE CONTAINS(Note, 'scout')
That query would raise the following error:
Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'EmployeesView' because it is not full-text indexed.
I would like to understand why it isn't possible for a view to run a FTS against its underlying table like it does for other regular indexes?
Note #1 This question isn't about how to create a full text index on a view as this as already been answered. This question is to understand why we have to do it.
Note #2 Our database is more complex than the provided example. We have many views using the same full text indexed table, some can be indexed while others cannot because of the schema binding restriction. I also think it's a bit odd (and a huge disk space waste) to add a FTI to every single view if each of them would identical.
WITH VIEW_METADATA
defined on theVIEW
? – NomotheticVIEW_METADATA
but it didn't help. – TanaVIEW_METADATA
might explain it (because usingVIEW_METADATA
actually hides theBASE TABLE
and other metadata from the rest of the system which I thought would explain why you had issues with full-text indexes on the view but not the table... but nvm :) – Nomothetic