For a particular requirement we have - we need to do a query that is a
combination of multiple dismax queries behind the scenes. (Using solr
1.4 nightly ).
The DisMaxQParser org.apache.solr.search.DisMaxQParser ( details at -
http://wiki.apache.org/solr/DisMaxRequestHandler ) takes in the /qf/
parameters and applies the parser to /q /and computes relevance based on
the same.
We need to have a case where, the final query is a combination of {
(q => keywords, qf => Map of field weights) , (q1, qf1 ) , (q2,
qf2 ) .. etc } combined by a boolean AND , for the individual queries.
Creating a custom QParser works right away as below.
public class MultiTermDisMaxQParser extends DisMaxQParser
{
..
..
..
@Override
public Query parse() throws ParseException
{
BooleanQuery finalQuery = new BooleanQuery(true);
Query superQuery = super.parse(); // Handles { (q, qf) combination }.
...
...
// finalQuery adds superQuery with a weight.
return finalQuery;
}
}
Curious to see if we have an alternate method to implement the same /
any other alternate suggestions to the problem itself.