Today’s tip is from Marius Agur Hagelund “Viking” Lind (actually, I’m confused, perhaps it’s Marius “Viking” Agur Hagelund Lind?). Got a tip of your own? Send it to email@example.com.
Cannot use CONTAINS or FREETEXT predicate on table or indexed view because it is not full-text indexedMean SQL Server
Cannot use CONTAINS or FREETEXT predicate on table or indexed view because it is not full-text indexed
ever got this error message it’s probably because you tried searching using the
SDK using the contains keyword on a field which isn’t full-text indexed.
For me it was searching for systemusers:
I got the following nice error message in return,
which puzzled me at first
Cannot use a CONTAINS or FREETEXT predicate on table
or indexed view 'SystemUserBase' because it is not full-text indexed.
checking in the system, and found that I could search for names there when I
used wildcard characters, and then it dawned on me that all these years of
autocomplete, intellisense and helpers have made my lazy and dumb. Using
wildcards is not the same as using CONTAINS, which is very obvious if you take
a SQL Server 101 course found anywhere, so the solution was as easy as this:
But what about the web api? Well, turns out they removed the Microsoft.Dynamics.Crm.Contains action and only use the Contains keyword (api/data/v9.1/systemusers?$contains(firstname, ‘mike d’). That is, unless you want to perform a full-text search in knowledge base articles:
So lesson learned: Stop being a dinosaur and start using the web api.
Cover photo by Daiga Ellaby