SearchGrammar - AND'ed terms always TermType.Inflectional?

Jul 26, 2012 at 10:08 AM

I have a question about TermType in the SearchGrammar sample. If this is the wrong forum for this, please forgive. 

It seems to me that TermType will always be Inflectional for AND'ed terms, no matter what TermType you hand ConvertQuery()

Example with FTS TermType=Exact:

AND Query: classical music
Fts:  ( FORMSOF (INFLECTIONAL, classical)  AND  FORMSOF (INFLECTIONAL, music) )

OR Query: classical | music
Fts:  (classical OR music)

In line 121 of SearchGrammar.cs, the TermType is set explicitly to Inflectional for AND but not for negation or OR. 

              switch(op) {
                case "":  case "&":  case "and":
                  sqlOp = " AND ";
                  type = TermType.Inflectional;
                  break;
                case "-":
                  sqlOp = " AND NOT ";
                  break;
                case "|":   case "or":
                  sqlOp = " OR ";
                  break;
              }//switch

Is there a reason for this, am I missing something?

Really, really nice work, by the way. 

Coordinator
Jul 26, 2012 at 5:56 PM

Here is a fragment from original Michal's code:

 

case "OrExpression":
				result = "(" + ConvertQuery(node.ChildNodes[0], type) + " OR " +
				ConvertQuery(node.ChildNodes[2]) + ")";
				break;
case "AndExpression": AstNode tmp2 = node.ChildNodes[1]; string opName = tmp2.Term.Name; string andop = ""; if (opName == "-") { andop += " AND NOT "; } else { andop = " AND "; type = TermType.Inflectional; } result = "(" + ConvertQuery(node.ChildNodes[0], type) + andop + ConvertQuery(node.ChildNodes[2]) + ")"; type = TermType.Inflectional; break;

 

I "blindly" copied his code with some refactoring, but as you see, the same thing happens for AND expression only, but not for OR. Ask Michael Coles himself on SQL Central forum for the article:

http://www.sqlservercentral.com/articles/Full-Text+Search+(2008)/64248/

Roman