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 Kay Kay <ka...@gmail.com> on 2009/09/23 21:15:10 UTC

Multiple DisMax Queries spanning across multiple fields

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.





Re: Multiple DisMax Queries spanning across multiple fields

Posted by Chris Hostetter <ho...@fucit.org>.
: 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 ).
	...
: Creating a custom QParser works right away  as below.   
	...
: Curious to see if we have an alternate method to implement the same / any
: other alternate suggestions to the problem itself.

if your sets of q params are coming from the same source as your sets 
of qf params (ie: some complicated client code) then i probably would 
have just written a parser that had special markup for indicating a 
DisMaxQuery and let the client pass a complex string (that way you won't 
have to worry about changing the logic in your QParser if you get a 
request to structure the DisMaxQeries in a diffenret super query, the 
client can just do the restrcuturing).

But if you're still in the spirit of the dismaax handler (query strings 
come from clients, qf and pf come from index owner) then i think you made 
teh right call.



-Hoss