Hi,

Yes, please, file a bug at https://issues.apache.org/jira/ and, if possible, a patch. It helps us keep track of changes made between versions (and thus, a changelog).

// Simon

On 2012-11-15 18:06, Hadrien Hugot wrote:
Hi all,

I found a regression between Lucene 2.9.4g and Lucene 3.0.3 in the method 
GetFieldQuery of MultiFieldQueryParser with the boosts factor.

public class MultiFieldQueryParser : QueryParser
{

    protected internal override Query GetFieldQuery(string field, string 
queryText, int slop)
         {
             if (field == null)
             {
                 IList<BooleanClause> clauses = new List<BooleanClause>();
                 for (int i = 0; i < fields.Length; i++)
                 {
                     Query q = base.GetFieldQuery(fields[i], queryText);
                     if (q != null)
                     {
                         //If the user passes a map of boosts
                         if (boosts != null)
                         {
                             //Get the boost from the map and apply them
                             Single boost = boosts[fields[i]];
                             q.Boost = boost;
                         }
...

If all fields don't have a boost factor an exception is throw by "Single boost = 
boosts[fields[i]];"
In version 2.9.4g, a check was performed, and no boost were apply if the field 
is not boosted.

I think that we should correct this by:
if (boosts != null)
{
                 //Get the boost if exists and apply them
float boost;
if (boosts.TryGetValue(fields[fieldIdx], out boost))
                                 q.Boost = boost;
}


Should I create a bug for this ? Can I submit a patch ?

Best Regards,

Hadrien


Reply via email to