lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hadrien Hugot <hadrien.hu...@rimes.com>
Subject GetFieldQuery in MultiFieldQueryParser
Date Thu, 15 Nov 2012 17:06:00 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message