You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Paul Libbrecht <pa...@hoplahup.net> on 2011/03/16 08:13:04 UTC
query expansion à la dismax
Hello list,
the dismax query type has one feature that is particularly nice... the ability to expand tokens to a query to many fields. This is really useful to do such jobs as "prefer a match in title, prefer exact matches over stemmed matches over phonetic matches".
My problem: I wish to do the same with the normal Lucene query type because I wish to enable power users to use some syntax if they wish but I would still like to expand on searches in the default field that are on the top level.
So I wrote my own code that filters the top level queries and expands them, using a similar instruction as dismax within a particular query component.
Question 1: doesn't such a code already exist?
(I haven't found it)
Question 2: should I rather make a QParserPlugin?
(the javadoc is not very helpful)
thanks in advance
paul
Re: query expansion à la dismax
Posted by Chris Hostetter <ho...@fucit.org>.
: So I wrote my own code that filters the top level queries and expands
: them, using a similar instruction as dismax within a particular query
: component.
:
: Question 1: doesn't such a code already exist?
: (I haven't found it)
the DisjunctionMaxQueryParser class has support for configuring field
aliase -- in the DisMaxQParser it only uses it with setting up aliaes for a
(fake) default field, but if you use it directly in code you can set up
specific aliases for specific field names (there's plans to do this for
the edismax handler but some other weird behavior bugs are holding it up)
: Question 2: should I rather make a QParserPlugin?
: (the javadoc is not very helpful)
implementing QParserPlugin is how you register a plugin that solr knows
to use to parse query strings when the user asks for a parser by name
(either using the defType param, or with the local param syntax). within
your QParserPlugin you can implement the actaul parsing anyway you like.
The LuceneQParserPlugin serves as a really simple example of how to
implement a QParserPlugin if you've already got a QueryParser subclass
that you want to use -- it's really just about managing the request
parameters.
-Hoss