Search Grammar enhancement for inurl

Jun 2, 2010 at 9:04 AM
Hi guys, I am thinking to enhance the current Search Grammar class for FTS by allowing the user to enter for example inurl:times as a search query. This, obviously should not compromise the existing functionality of Search Grammar but provides additional functionality. A possible search string could be something like inurl:times -british etc... Did anyone already triy accomplish this? I would appreciate suggestions / help on how to accomplish this from you guys :) Thanks and regards, J
Jun 5, 2010 at 12:32 AM

Hi J

The first thing to do is define what the inurl: indicates.  I played with the idea of using inurl: to indicate a specific table that should be queried with iFTS, so in AdventureWorks you might have something like this:

Person.Address:oak

Of course if might make more sense to give your inurl: a friendly name that maps to a database table:

address:oak

You don't have to go with this, but I couldn't think of what else the inurl: would be useful for.  Download the sample code from the Irony site and change these lines:

BinaryOp.Rule = ImpliedAnd | "and" | "&" | "-" | "or" | "|" | ":"; /* Change line 41 */
RegisterOperators(30, ":"); /* Insert this between lines 58 and 60 */

This will create a new ":" BinaryOperator with higher precedence than AND and OR.  When you run the GrammarExplorer on it you'll see it's captured as a BinaryExpression like this:

BinaryExpression
     |
     |---address (Term)
     |---: (Key symbol)
     |---oak (Term)

You'll need to add the handling for the new BinaryExpression in the ConvertQuery function around line 113 or so.  If you decide to use inurl: to select a table to query the tricky part would be that FTS doesn't support querying multiple tables at once, so you'd have to build out individual iFTS queries for each table and UNION them together when you run them against the server.  This added complexity is the main reason I didn't add this functionality to the original search query grammar.  Basically you'll have to build and keep track of multiple iFTS query strings simultaneously and then pull them all together at some point.  You also have to decide what it means to retrieve results of a search like this:

address:oak AND product:crankarm

In this example there's no direct relationship between the two tables being queried (although you could probably use some indirect relationship through customer orders, for instance, to bring together addresses and products -- but does that make sense for your application?)  Of course you may not want to use the inurl: to direct iFTS to search a table (you may have another purpose for it), so that may not be a concern for you.

Thanks

Michael Coles

Jun 9, 2010 at 1:26 PM

Hi Michael,

I will definately give your idea a try and check out the progress. As you mentioned, I would need to inurl to directly query a particular table column. The SQL generation would also need to be modified quite a lot to make this task work.

I will post any new developments regarding this.

Thanks for your reply.

Cheers,

J

Jun 9, 2010 at 2:35 PM
Hi J

Sounds good. I'd be interested in hearing more about the AND, OR and NOT rules you decide to apply across multiple tables with the inurl: feature once you've made those decisions.

Thanks
Michael

Sent via BlackBerry from T-Mobile


From: "jonimatix" <notifications@codeplex.com>
Date: 9 Jun 2010 05:26:52 -0700
To: <admin@geocodenet.com>
Subject: Re: Search Grammar enhancement for inurl [irony:214681]

From: jonimatix

Hi Michael,

I will definately give your idea a try and check out the progress. As you mentioned, I would need to inurl to directly query a particular table column. The SQL generation would also need to be modified quite a lot to make this task work.

I will post any new developments regarding this.

Thanks for your reply.

Cheers,

J

Jun 15, 2010 at 3:25 PM

Hi Michael,

I started out with from your suggestions and it definately is the best way to go. The BinaryOp.Rule = ImpliedAnd | "and" | "&" | "-" | "or" | "|" | ":" should divide the user input string into terms and RegisterOperators(30, ":"); should give higher prcedence in the AST tree.

Taking your example, if a user searches for address:oak -tree, how do you think is best to alter ConvertQuery, however? Which case for node.Term.Name should be altered (around line 107), since we have not created a new non-terminal? 

 

Thanks for your input.

Regards,

J

 

 

 


 

Jun 15, 2010 at 3:38 PM
I'll have to look at the code to give you specifics (can't acces it right now), but essentially you would be treating it like the "or" or "and" operators. So you could model your code from them.

Thanks
Mike C
Sent via BlackBerry from T-Mobile
Jun 16, 2010 at 8:45 AM

Hi Michael,

Following the previous comment, I think there are 2 ways of achieving this.. Either giving the highest prioirty to the operator ":", or else create a new non-terminal that would override the Root expression with the new nonterminal, like the following:

          var columnLookup = new NonTerminal("columnLookup");

          this.Root = columnLookup;
          columnLookup.Rule = columnLookup + ":" + Expression;

If the path not to create a nonterminal is taken, can you give advice on how to give the highest priority, so that when user inputs address:oak -tree it is represented as address:(oak -tree ) and not as currently represented (address:oak) -tree

I appreciate you suggestions in this regard,

Regards,

J

 

Jun 16, 2010 at 3:55 PM
Hi J

I don't believe it it possible (or at least it will be too difficult for its value) to fulfill this requirement with the nonterminal change. A question--do you wish to allow a user to specify more than one "columnLookup" per query? If so you might be getting into some ambiguity, if not on the syntax, I think on the iFTS side.

Thanks
Mike C

Sent via BlackBerry from T-Mobile


From: "jonimatix" <notifications@codeplex.com>
Date: 16 Jun 2010 00:45:02 -0700
To: <admin@geocodenet.com>
Subject: Re: Search Grammar enhancement for inurl [irony:214681]

From: jonimatix

Hi Michael,

Following the previous comment, I think there are 2 ways of achieving this.. Either giving the highest prioirty to the operator ":", or else create a new non-terminal that would override the Root expression with the new nonterminal, like the following:

var columnLookup = new NonTerminal("columnLookup");

this.Root = columnLookup;
columnLookup.Rule = columnLookup + ":" + Expression;

If the path not to create a nonterminal is taken, can you give advice on how to give the highest priority, so that when user inputs address:oak -tree it is represented as address:(oak -tree ) and not as currently represented (address:oak) -tree

I appreciate you suggestions in this regard,

Regards,

J