Troubleshooting your FORMSOF & INFLECTIONAL searches not working, SQL Server 2005

For the life of me, I couldn’t figure out why I didn’t get different results, using SQL Server 2005, for a simple Full-Text Search query and a Full-Text Search query using the FORMSOF and INFLECTIONAL keywords.

What I stumbled across eventually was that when creating and configuring my SQL Full-Text Indexes, I had left the language parameter as the default selection. When I changed this to English, voila!, my FORMSOF (INFLECTIONAL, @query) queries started to produces fantastic search results!

Also, an example query showing how to parameterize the the search term, and how to rank your results:

@query varchar (100)

SET @query = ‘FORMSOF (INFLECTIONAL, ‘ + @query + ‘)’

SELECT FT.rank, P.id, P.title
FROM Products P
INNER JOIN CONTAINSTABLE (Products, *, @query) AS FT ON P.id = FT.[key]

If you’ve any questions, I’ll do my best to help. Also, if you’re just starting with Full-Text, check out my posts on installing Full-Text Search on SQL Server 2005 and how to setup and configure SQL Server 2005 Express Full-Text Search the easy way.

7 Responses to Troubleshooting your FORMSOF & INFLECTIONAL searches not working, SQL Server 2005

  1. Pingback: SQL Server 2005 Express Full-Text Search Setup Tutorial - Web Strategy Blog

  2. Sean says:

    Is there a table that can be viewed to show what the variations of inflectional words are? I need to do inflectional searches based upon a list of about 400 words, but I don’t know if all of the words I’m expecting to be found will be.

  3. Abhang says:

    Hi there,
    I am having a tough time with these indices. I believe I have all right installation for full text. A query like select * from Item
    where contains(title, ‘used and chair and pune’) returns the result I want, but a query like select * from Item
    where contains(title, ‘((formsof(inflectional,used)) and (formsof(inflectional,chair)) and (formsof(inflectional,pune)))’)

    does not return anything. So is this something to do with the way inflectional keyword works? Any comments appreciated.

  4. Iain says:

    Hi Abhang, I’m can’t say for sure why you’re query isn’t working, but I see several differences between your proposed query and the example I provide.

    Firstly, you’re using CONTAINS and not CONTAINSTABLE. If you use CONTAINSTABLE, note that its joined using INNERJOIN to the table you’re searching, and it’s parameters are the table name, column names, and then your query.

    Finally, you’re applying FORMSOF to each query term individually – in my example I put the whole query together, and that works fine for me.

    Good luck, let me know how you get on.

  5. Abhang says:

    Howdy,
    Thanks dude. Actually the way I was building the query string was incorrect. I had too many ( and ) in the query. Just plain ‘formsof(inflectional,used) and formsof(inflectional,chair)’ works. I am planning to create a Thesaurus for improving the search quality, lets see how that goes.

  6. Tyler Collier says:

    Thanks for two tips here. One, the language. I would’ve thought the default “Neutral” language would have been acceptable, but alas, it was not. Two, showing how to parameterize was good because I foolishly left my parameter within single quotes, so it looked like this at first:

    contains(FieldName, ‘FORMSOF (INFLECTIONAL, @SearchText) ‘)

    With your help, I realized this had to be changed to be more like yours where I put @SearchText, as well as the ‘FORMSOF (INFLECTIONAL)’ portion inside another variable.

    Thanks!

  7. abhimanyu says:

    my sql connection is not establishing in sql server authentication.it is showing an error that the user is notassosiated with a trusted sql server connection

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

"Personable, Good Value, High Integrity."

Marie-Noelle Douaiher
APC

Think we may be able to help you? Why not start a conversation - chances are, you'll go away with some new ideas and knowledge.