Example #1
0
        protected internal override Query GetFieldQuery(System.String field, System.String queryText, int slop)
        {
            if (field == null)
            {
                System.Collections.IList clauses = new System.Collections.ArrayList();
                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
                            if (boosts.Contains(fields[i]))
                            {
                                System.Single boost = (System.Single)boosts[fields[i]];
                                q.SetBoost((float)boost);
                            }
                        }
                        ApplySlop(q, slop);
                        clauses.Add(new BooleanClause(q, BooleanClause.Occur.SHOULD));
                    }
                }
                if (clauses.Count == 0)
                {
                    // happens for stopwords
                    return(null);
                }
                return(GetBooleanQuery(clauses, true));
            }
            Query q2 = base.GetFieldQuery(field, queryText);

            ApplySlop(q2, slop);
            return(q2);
        }