I have a query which is fairly complex and refers to a joined table-pair a number of times. To simplify the query and improve performance, I've pulled that table pair out into a sub query.
However, now my full text index doesn't work, stating that CTE_Query.Indexedfield is not full text indexed.
Super simplified example query below
WITH CTE_Query AS
(
SELECT ID, IndexedField
FROM IndexedTable it
INNER JOIN SomeOtherTable sot
ON sot.itid = it.id
WHERE blahblah...
)
SELECT CTE_Query.ID, CTE_Query.IndexedField
FROM CTE_Query
WHERE CONTAINS(CTE_Query.IndexedField, 'Some search term')
UNION ALL
SELECT CTE_Query.IndexedField
FROM CTE_Query
WHERE CONTAINS(CTE_Query.IndexedField, 'Another search term')
-- This part of the query is complex and re-uses the CTE_Query and other tables a number of times, I've simplified it here
When executing, I get the following error
Cannot use a CONTAINS or FREETEXT predicate on column 'IndexedField' because it is not full-text indexed.
This suggests that SQL Server loses track of the fact that this just an alias to a full text indexed field.
Is there any way to force SQL Server to apply a specific full text index here? Or is this just part of how a full text index works? I guess it's likely that the index relies on having access to the original table, but I'm not sure how it works underneath