MuliField Query Parser

2006-03-08 Thread Raghavendra Prabhu
Hi

I need different boosts for fields which we define in multifield query
parser

How can this be accomplished??


Rgds
Prabhu


Re: MuliField Query Parser

2006-03-08 Thread Rainer Dollinger
You could try to inherit from MultiFieldQueryParser:

public class BoostableMultiFieldQueryParser extends MultiFieldQueryParser {

// TODO: add constructors of super class


public static Query parse(String query, String[] fields,
BooleanClause.Occur[] flags,Analyzer analyzer, float[]
boosts) throws ParseException {
  if (fields.length != flags.length)
throw new IllegalArgumentException(fields.length !=
flags.length);
  BooleanQuery bQuery = new BooleanQuery();
  for (int i = 0; i  fields.length; i++) {
QueryParser qp = new QueryParser(fields[i], analyzer);
Query q = qp.parse(query);

// ATTENTION: the only new line !!!
q.setBoost(boost[i]);

bQuery.add(q, flags[i]);
  }
  return bQuery;
}
}

I copied the code of method parse(String, String, BooleanClause.Occur[],
Analyzer) and added the parameter float[] boosts.
I marked the only line I have inserted.
You have to add the constructors from the super class to get the class
compiled.

I did'nt have the time to test this idea, please post a reply if it
works, if you try this.

Rainer



Raghavendra Prabhu wrote:
 Hi
 
 I need different boosts for fields which we define in multifield query
 parser
 
 How can this be accomplished??
 
 
 Rgds
 Prabhu
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]