On Jun 4, 2006, at 8:55 PM, Daniel Noll wrote:
Erik Hatcher wrote:
On Jun 4, 2006, at 5:57 PM, karl wettin wrote:
I was thinking it could be nice if the query parser handled
aliases by
passing a Map to the parser. The data could be compiled from the
index.
"name", "nam", "na" and "n" all trigger on "name", taking there
is no
other field starting with an "n".
Did anyone implement this, or should I hack one up?
Rather than hacking QueryParser, simply do some regex replaces on
the string before handing it to parser. n:karl would get replaced
with name:karl. ([a-z]*)\: replaced with the field name that
matches $1.
It seems a little more elegant to extend from QueryParser in this
situation. Override getFieldQuery which gets passed the field name
string, and all you'd have to do is call the method in the
superclass after modifying the field name. Done, and no regexes
required.
Indeed! I agree - I was temporarily blinded by the desire to hack
QueryParser itself in perhaps a one-off way that I didn't consider
the subclassing option.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]