1

I have a search box where users can enter text, when they hit search the text they entered will then be used in a SQL CONTAINSTABLE statement. I need to parse the string so that it is in an appropriate format for the CONTAINSTABLE function, and I have found an example that uses Irony that almost does exactly what I need. I got the Irony sample class here:

http://irony.codeplex.com/SourceControl/latest#Irony.Samples/FullTextSearchQueryConverter/SearchGrammar.cs

which is actually designed for the SQL CONTAINS function but the difference between that and CONTAINSTABLE aren't a problem for me at the minute. I made a slight modification in that I didn't want the 'Inflectional' behaviour, so I changed any references of that to be 'Exact'.

The problem I am having now is that I want a search phrase to be treated as a phrase, rather than as a list of keywords separated by an AND operator. So for example, if a user enters: "General manager", then I want it to come through the parser as "General manager" but it's currently bringing back "General" AND "manager"

I think I need to modify the constructor somehow, where it is building all the expression rules - but I'm not even sure where to start on that!

Any help greatly appreciated, thanks.

iamdave
  • 12,023
  • 3
  • 24
  • 53
Matt F
  • 129
  • 1
  • 8
  • Looks like it is the `ImpliedAnd` that is giving the behaviour you don't want. Have you tried removing that? – Jack Hughes Dec 14 '16 at 14:50
  • Hi @JackHughes, thanks for the reply. I did try that after I'd got my head round the whole thing a bit more. I still couldn't get it to do what I wanted originally but in the end I decided to use it as in the code example I posted, so phrases have to be enclosed with double quotes. There was also a 'FreeTextLiteral' object which looked promising but I didn't have the time to explore that fully - might help anyone else who sees this post though! – Matt F Dec 16 '16 at 15:20

0 Answers0