Exemplo n.º 1
0
 public static void AddQueriesToBoolean(
     BooleanQuery bq,
     IList <Search.Query> queries,
     Occur occur)
 {
     foreach (var query in queries)
     {
         bq.Add(query, occur);
     }
 }
Exemplo n.º 2
0
        /*
         * Makes a boolean query based upon a collection of queries and a logical operator.
         *
         * @param queries the query collection
         * @param occur the logical operator
         * @return the query
         */
        BooleanQuery MakeQuery(Query[] queries, Occur occur)
        {
            var bq = new BooleanQuery();

            foreach (Query query in queries)
            {
                bq.Add(query, occur);
            }
            return(bq);
        }
 private static void AssertResult(LuceneQueryPredicateExpression result, Occur expectedOccur)
 {
     Assert.That(result, Is.Not.Null, "Expected LuceneQueryPredicateExpression to be returned.");
     Assert.That(result, Is.Not.SameAs(predicate));
     Assert.That(result.QueryField, Is.SameAs(predicate.QueryField));
     Assert.That(result.QueryPattern, Is.SameAs(predicate.QueryPattern));
     Assert.That(result.QueryType, Is.EqualTo(predicate.QueryType));
     Assert.That(result.Occur, Is.EqualTo(expectedOccur));
     Assert.That(result.Boost, Is.EqualTo(predicate.Boost));
     Assert.That(result.AllowSpecialCharacters, Is.EqualTo(predicate.AllowSpecialCharacters));
 }
 protected internal new LuceneBooleanOperationBase IdInternal(
     string id,
     Occur occurrence)
 {
     if (id == null)
     {
         throw new ArgumentNullException(nameof(id));
     }
     this.Query.Add(this._queryParser.GetFieldQueryInternal("__NodeId", id), occurrence);
     return(this.CreateOp());
 }
Exemplo n.º 5
0
        public QueryProvider <TLuceneEntity> Open(Occur occur)
        {
            _prev = _current;

            var subQuery = new BooleanQuery();

            _current.Add(subQuery, occur);

            _current = subQuery;

            return(this);
        }
Exemplo n.º 6
0
 public static System.String ToString(this Occur occur)
 {
     if (occur == Occur.MUST)
     {
         return("+");
     }
     if (occur == Occur.MUST_NOT)
     {
         return("-");
     }
     return("");
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Add a query to <paramref name="combinedQuery"/>.
        /// </summary>
        /// <param name="combinedQuery">
        ///     Query combining other ones
        /// </param>
        /// <param name="query">
        ///     Optional, nothing done if null
        /// </param>
        /// <param name="occur">
        ///     How to treat <paramref name="query"/>
        /// </param>
        /// <returns>
        ///     <paramref name="combinedQuery"/> for chaining
        /// </returns>
        public static BooleanQuery Add(this BooleanQuery combinedQuery, Query query, Occur occur)
        {
            Check.DoRequireArgumentNotNull(combinedQuery, nameof(combinedQuery));

            if (query == null)
            {
                return(combinedQuery);
            }

            combinedQuery.Add(query, occur);
            return(combinedQuery);
        }
Exemplo n.º 8
0
        public static BooleanQuery CreateBooleanQuery(Occur oOccur, params Query[] oQueries)
        {
            BooleanQuery oBooleanQuery = new BooleanQuery();

            foreach (Query oQuery in oQueries)
            {
                if (oQuery != null)
                {
                    oBooleanQuery.Add(oQuery, oOccur);
                }
            }
            return(oBooleanQuery);
        }
Exemplo n.º 9
0
        public static Search.Query MakeBooleanQuery(
            IList <Search.Query> queries,
            Occur occur)
        {
            if (queries.Count <= 1)
            {
                throw new InvalidOperationException("Too few subqueries: " + queries.Count);
            }
            BooleanQuery bq = new BooleanQuery();

            AddQueriesToBoolean(bq, queries, occur);
            return(bq);
        }
Exemplo n.º 10
0
        public static Search.Query MakeBooleanQuery(
            IList <Search.Query> queries,
            Occur occur)
        {
            if (queries.Count <= 1)
            {
                throw AssertionError.Create("Too few subqueries: " + queries.Count);
            }
            BooleanQuery bq = new BooleanQuery();

            AddQueriesToBoolean(bq, queries, occur);
            return(bq);
        }
Exemplo n.º 11
0
        public static BooleanQuery AddNumericRangeQuery <TObj>(
            this BooleanQuery instance,
            Expression <Func <TObj, int?> > expression,
            int lowerInclusive,
            int upperInclusive,
            Occur occur)
        {
            string indexName = ExpressionExtensions.GetIndexName(expression);
            var    query     = NumericRangeQuery.NewIntRange(indexName, lowerInclusive, upperInclusive, true, true);

            instance.Add(query, occur);
            return(instance);
        }
Exemplo n.º 12
0
        public List <Item> search(string keyWord)
        {
            //string strAnalyzerType = comboBox2.SelectedItem.ToString();
            string strAnalyzerType = "StandardAnalyzer";

            if (comboBox2.SelectedItem != null)
            {
                strAnalyzerType = comboBox2.SelectedItem.ToString();
            }
            string strType = "A";

            if (textBox3.Text != "")
            {
                strType = textBox3.Text.ToString();
            }
            FSDirectory dir     = FSDirectory.Open(indexLocation);
            List <Item> results = new List <Item>();

            Lucene.Net.Util.Version      AppLuceneVersion = Lucene.Net.Util.Version.LUCENE_30;
            Lucene.Net.Analysis.Analyzer analyzer         = AnalyzerHelper.GetAnalyzerByName(strAnalyzerType);
            //Lucene.Net.QueryParsers.MultiFieldQueryParser parser = new Lucene.Net.QueryParsers.MultiFieldQueryParser(AppLuceneVersion,new string[] { "content","title" }, analyzer);
            IDictionary <String, Single> dictionary = new Dictionary <String, Single>();

            dictionary.Add("title", 5);
            dictionary.Add("content", 10);
            Lucene.Net.QueryParsers.MultiFieldQueryParser parser = new Lucene.Net.QueryParsers.MultiFieldQueryParser(AppLuceneVersion, new string[] { "title", "content" }, analyzer);
            //parser.DefaultOperator = Lucene.Net.QueryParsers.QueryParser.Operator.AND;
            Lucene.Net.Search.Query query = parser.Parse(keyWord);
            //parser.
            //BooleanClause
            //Lucene.Net.Search.BooleanClause booleanClauses = new BooleanClause();
            //BooleanClause
            //    BooleanClause.Occur[] flags = new BooleanClause.Occur[] { BooleanClause.Occur.MUST, BooleanClause.Occur.MUST };
            Occur[] occurs = new Occur[] { Occur.MUST, Occur.MUST };
            Lucene.Net.Search.Query query2 = Lucene.Net.QueryParsers.MultiFieldQueryParser.Parse(AppLuceneVersion, new string[] { keyWord, strType }, new string[] { "content", "title" }, occurs, analyzer);

            Lucene.Net.Search.IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir);
            TopDocs topdocs = searcher.Search(query2, 100);

            Lucene.Net.Search.ScoreDoc[] hits = topdocs.ScoreDocs;

            foreach (var hit in hits)
            {
                var foundDoc = searcher.Doc(hit.Doc);
                results.Add(new Item {
                    title = foundDoc.Get("title"), content = foundDoc.Get("content")
                });
            }
            searcher.Dispose();
            return(results);
        }
Exemplo n.º 13
0
        public static Filter CreateQuery(ISearchCriteria criteria, ISearchFilter filter, Occur clause)
        {
            var values = GetFilterValues(filter);
            if (values == null) return null;

            var query = new BooleanFilter();
            foreach (var value in values)
            {
                var valueQuery = CreateQueryForValue(criteria, filter, value);
                query.Add(new FilterClause(valueQuery, Occur.SHOULD));
            }

            return query;
        }
Exemplo n.º 14
0
        /// <summary>
        /// verify parsing of query using a stopping analyzer
        /// </summary>
        /// <param name="qtxt"></param>
        /// <param name="expectedRes"></param>
        private void AssertStopQueryEquals(string qtxt, string expectedRes)
        {
            string[] fields = { "b", "t" };
            Occur[]  occur  = new Occur[] { Occur.SHOULD, Occur.SHOULD };
            TestQueryParser.QPTestAnalyzer a    = new TestQueryParser.QPTestAnalyzer();
            MultiFieldQueryParser          mfqp = new MultiFieldQueryParser(TEST_VERSION_CURRENT, fields, a);

            Query q = mfqp.Parse(qtxt);

            assertEquals(expectedRes, q.toString());

            q = MultiFieldQueryParser.Parse(TEST_VERSION_CURRENT, qtxt, fields, occur, a);
            assertEquals(expectedRes, q.toString());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new <see cref="Option"/>.
        /// </summary>
        /// <param name="shortName">
        /// The short name of the command line option.
        /// </param>
        /// <param name="longName">
        /// The long name of the command line option.
        /// </param>
        /// <param name="arguments">
        /// The occurence of a argument after the command line option.
        /// </param>
        /// <param name="occurs">
        /// The occurance of the command line option.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="shortName"/> or <paramref name="longName"/> is
        /// <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="arguments"/> or <paramref name="occurs"/> is
        /// invalid.
        /// <paramref name="shortName"/> and <paramref name="longName"/> are
        /// empty.
        /// <paramref name="shortName"/> or <paramref name="longName"/> contain
        /// invalid white space or control characters.
        /// </exception>
        public Option(
            string shortName,
            string longName,
            Argument arguments,
            Occur occurs)
        {
            shortName = Format(shortName, nameof(shortName));
            longName  = Format(longName, nameof(longName));

            if (shortName == string.Empty && longName == string.Empty)
            {
                throw new ArgumentException(
                          $"{nameof( shortName )} and {nameof( longName )} are empty",
                          $"{nameof( shortName )}, {nameof( longName )}");
            }

            ShortName = shortName;
            LongName  = longName;

            Arguments = (byte)arguments <= 0x02
                ? arguments
                : throw new ArgumentException(
                                  $"Invalid {nameof(Argument)} option {arguments}",
                                  nameof(arguments));

            Occurs = (byte)occurs <= 0x02
                ? occurs
                : throw new ArgumentException(
                               $"Invalid {nameof(Occur)} option {occurs}",
                               nameof(occurs));

            string Format(string name, string paramName)
            {
                if (name == null)
                {
                    throw new ArgumentNullException(paramName);
                }
                name = name.Trim();
                if (name.Any(
                        x => char.IsWhiteSpace(x) || char.IsControl(x)))
                {
                    throw new ArgumentException(
                              paramName
                              + " must not contain control or white space characters",
                              paramName);
                }
                return(name);
            }
        }
        private BooleanQuery GetMultiFieldQuery(
            IReadOnlyList <string> fields,
            IExamineValue[] fieldVals,
            Occur occurrence,
            bool matchAllCombinations = false)
        {
            var qry = new BooleanQuery();

            if (matchAllCombinations)
            {
                foreach (var f in fields)
                {
                    foreach (var val in fieldVals)
                    {
                        var q = GetFieldInternalQuery(f, val, true);
                        if (q != null)
                        {
                            qry.Add(q, occurrence);
                        }
                    }
                }
            }
            else
            {
                var queryVals = new IExamineValue[fields.Count];
                if (fieldVals.Length == 1)
                {
                    for (int i = 0; i < queryVals.Length; i++)
                    {
                        queryVals[i] = fieldVals[0];
                    }
                }
                else
                {
                    queryVals = fieldVals;
                }

                for (int i = 0; i < fields.Count; i++)
                {
                    var q = GetFieldInternalQuery(fields[i], queryVals[i], true);
                    if (q != null)
                    {
                        qry.Add(q, occurrence);
                    }
                }
            }

            return(qry);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Converts a Lucene boolean occurrence to an Examine representation
        /// </summary>
        /// <param name="o">The occurrence to translate.</param>
        /// <returns>The translated boolean occurrence</returns>

        public static BooleanOperation ToBooleanOperation(this Occur o)
        {
            if (o == Occur.MUST)
            {
                return(BooleanOperation.And);
            }
            else if (o == Occur.MUST_NOT)
            {
                return(BooleanOperation.Not);
            }
            else
            {
                return(BooleanOperation.Or);
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// Creates a new <see cref="CommonTermsQuery"/>
 /// </summary>
 /// <param name="highFreqOccur">
 ///          <see cref="Occur"/> used for high frequency terms </param>
 /// <param name="lowFreqOccur">
 ///          <see cref="Occur"/> used for low frequency terms </param>
 /// <param name="maxTermFrequency">
 ///          a value in [0..1) (or absolute number >=1) representing the
 ///          maximum threshold of a terms document frequency to be considered a
 ///          low frequency term. </param>
 /// <param name="disableCoord">
 ///          disables <see cref="Search.Similarities.Similarity.Coord(int,int)"/> in scoring for the low
 ///          / high frequency sub-queries </param>
 /// <exception cref="ArgumentException">
 ///           if <see cref="Occur.MUST_NOT"/> is pass as <paramref name="lowFreqOccur"/> or
 ///           <paramref name="highFreqOccur"/> </exception>
 public CommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur,
                         float maxTermFrequency, bool disableCoord)
 {
     if (highFreqOccur == Occur.MUST_NOT)
     {
         throw new System.ArgumentException("highFreqOccur should be MUST or SHOULD but was MUST_NOT");
     }
     if (lowFreqOccur == Occur.MUST_NOT)
     {
         throw new System.ArgumentException("lowFreqOccur should be MUST or SHOULD but was MUST_NOT");
     }
     this.m_disableCoord     = disableCoord;
     this.m_highFreqOccur    = highFreqOccur;
     this.m_lowFreqOccur     = lowFreqOccur;
     this.m_maxTermFrequency = maxTermFrequency;
 }
Exemplo n.º 19
0
 private void Combine(BooleanQuery target, BooleanQuery source, Occur occur)
 {
     if (source.GetClauses().Length == 1)
     {
         var clause = source.GetClauses()[0];
         if (clause.Occur == Occur.MUST)
         {
             clause.Occur = occur;
         }
         target.Add(clause);
     }
     else
     {
         target.Add(source, occur);
     }
 }
Exemplo n.º 20
0
        // LUCENENET specific - de-nested Occur from BooleanClause in order to prevent
        // a naming conflict with the Occur property

        public static string ToString(Occur occur)
        {
            switch (occur)
            {
            case Occur.MUST:
                return("+");

            case Occur.SHOULD:
                return("");

            case Occur.MUST_NOT:
                return("-");

            default:
                throw new ArgumentOutOfRangeException("Invalid Occur value");     // LUCENENET specific
            }
        }
Exemplo n.º 21
0
        private static Occur PrefixToOccurrence(LucenePrefixOperator prefix, Occur defaultOccurrence)
        {
            switch (prefix)
            {
            case LucenePrefixOperator.None:
                return(defaultOccurrence);

            case LucenePrefixOperator.Plus:
                return(Occur.MUST);

            case LucenePrefixOperator.Minus:
                return(Occur.MUST_NOT);

            default:
                throw new ArgumentOutOfRangeException("Unknown query prefix " + prefix);
            }
        }
Exemplo n.º 22
0
        private string ToString(Occur occur)
        {
            switch (occur)
            {
            case Occur.MUST:
                return("+");

            case Occur.SHOULD:
                return("");

            case Occur.MUST_NOT:
                return("-");

            default:
                throw new Exception("Invalid Occur_e value");
            }
        }
Exemplo n.º 23
0
        private Occur PrefixToOccurance(LuceneASTNodeBase node, Occur defaultOccurance)
        {
            switch (node.Prefix)
            {
            case PrefixOperator.None:
                return(defaultOccurance);

            case PrefixOperator.Plus:
                return(Occur.MUST);

            case PrefixOperator.Minus:
                return(Occur.MUST_NOT);

            default:
                throw new ArgumentOutOfRangeException("Unknown query prefix " + node.Prefix);
            }
        }
Exemplo n.º 24
0
        private void AddInternal(Query query, Occur occur, OperatorType @operator)
        {
            if (query is RavenBooleanQuery booleanQuery)
            {
                if (booleanQuery._operator == @operator && booleanQuery.AnyBoost == false)
                {
                    foreach (var booleanClause in booleanQuery.Clauses)
                    {
                        Add(booleanClause);
                    }

                    return;
                }
            }

            Add(query, occur);
        }
        public IActionResult Search(int areaID, string keyword, int pageIndex, int pageSize)
        {
            string[] fields = new[] { "name" };           //, "desc"

            Occur[] flags = new Occur[] { Occur.SHOULD }; //, Occur.SHOULD

            Sort sort = new Sort(new SortField("updatetime", SortField.STRING, true));

            int count = 0;

            var list = SearchHelper.AreaSearch(Location.OperatorArea, keyword, fields, flags, sort, pageIndex, pageSize, out count);

            return(Success(new
            {
                Count = count,
                Data = list
            }));
        }
Exemplo n.º 26
0
        /// <summary>
        /// Constructs a query to retrieve documents that fully contain the input envelope.
        /// </summary>
        private Query MakeWithin(IRectangle bbox)
        {
            var         bq   = new BooleanQuery();
            const Occur MUST = Occur.MUST;

            if (bbox.CrossesDateLine)
            {
                //use null as performance trick since no data will be beyond the world bounds
                bq.Add(RangeQuery(fieldNameX, null /*-180*/, bbox.MaxX), Occur.SHOULD);
                bq.Add(RangeQuery(fieldNameX, bbox.MinX, null /*+180*/), Occur.SHOULD);
                bq.MinimumNumberShouldMatch = 1; //must match at least one of the SHOULD
            }
            else
            {
                bq.Add(RangeQuery(fieldNameX, bbox.MinX, bbox.MaxX), MUST);
            }
            bq.Add(RangeQuery(fieldNameY, bbox.MinY, bbox.MaxY), MUST);
            return(bq);
        }
Exemplo n.º 27
0
        private static Query BuildFilter(FilterGroup filter, string cultureCode = "")
        {
            BooleanQuery q = new BooleanQuery();

            //if (filter.FilterRules.Count == 0 && filter.FilterGroups.Count == 0)
            //{
            //    q.Add(new MatchAllDocsQuery(), Occur.MUST);
            //}

            if (filter.FilterRules.Count > 0 && filter.FilterRules.All(r => r.FieldOperator == OperatorEnum.NOT_EQUAL))
            {
                q.Add(new MatchAllDocsQuery(), Occur.MUST);
            }

            Occur cond = Occur.MUST; // AND

            if (filter.Condition == ConditionEnum.OR)
            {
                cond = Occur.SHOULD;
            }
            AddRules(q, filter.FilterRules, cond, cultureCode);
            foreach (var rule in filter.FilterGroups)
            {
                Occur groupCond = Occur.MUST; // AND
                if (rule.Condition == ConditionEnum.OR)
                {
                    groupCond = Occur.SHOULD;
                }
                BooleanQuery groupQ = new BooleanQuery();
                AddRules(groupQ, rule.FilterRules, groupCond, cultureCode);
                q.Add(groupQ, cond);
            }
            q = q.Clauses.Count > 0 ? q : null;

            if (q == null)
            {
                return(_DefaultQuery);
            }

            return(q);
        }
Exemplo n.º 28
0
        public static BooleanQuery AddPhraseQuery(
            this BooleanQuery instance,
            string indexName,
            string value,
            Occur occur)
        {
            if (value != null)
            {
                value = value.ToLowerInvariant();

                var term     = new Term(indexName, value);
                var subQuery = new TermQuery(term);
                instance.Add(subQuery, occur);
            }
            else
            {
                var parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, indexName, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
                var query  = parser.Parse($"ISNULL:{indexName}");
            }
            return(instance);
        }
Exemplo n.º 29
0
        public virtual Filter GetFilter(XmlElement e)
        {
            BooleanFilter bf = new BooleanFilter();
            XmlNodeList   nl = e.ChildNodes;

            for (int i = 0; i < nl.Count; i++)
            {
                XmlNode node = nl.Item(i);
                if (node.LocalName.Equals("Clause", StringComparison.Ordinal))
                {
                    XmlElement clauseElem = (XmlElement)node;
                    Occur      occurs     = BooleanQueryBuilder.GetOccursValue(clauseElem);

                    XmlElement clauseFilter = DOMUtils.GetFirstChildOrFail(clauseElem);
                    Filter     f            = factory.GetFilter(clauseFilter);
                    bf.Add(new FilterClause(f, occurs));
                }
            }

            return(bf);
        }
Exemplo n.º 30
0
 private void  SetFields(Occur occur)
 {
     if (occur == Occur.MUST)
     {
         required   = true;
         prohibited = false;
     }
     else if (occur == Occur.SHOULD)
     {
         required   = false;
         prohibited = false;
     }
     else if (occur == Occur.MUST_NOT)
     {
         required   = false;
         prohibited = true;
     }
     else
     {
         throw new System.ArgumentException("Unknown operator " + occur);
     }
 }
Exemplo n.º 31
0
        private IndexQuery Boolean(Query query, Occur occur)
        {
            if (query == null)
            {
                return(this);
            }

            if (_nativeQuery is MatchAllDocsQuery)
            {
                _nativeQuery = query;
            }
            else
            {
                var newQuery = new BooleanQuery();
                newQuery.Add(_nativeQuery, occur);
                newQuery.Add(query, occur);

                _nativeQuery = newQuery;
            }

            return(this);
        }
Exemplo n.º 32
0
 public Clause(IFilterBuilder filterBuilder, Occur occur)
 {
     Filter = filterBuilder;
     Occur = occur;
 }
Exemplo n.º 33
0
 /// <summary> Builds a new BooleanClause instance</summary>
 /// <param name="q">sub query
 /// </param>
 /// <param name="occur">how this clause should occur when matching documents
 /// </param>
 /// <returns> new BooleanClause instance
 /// </returns>
 protected internal virtual BooleanClause NewBooleanClause(Query q, Occur occur)
 {
     return new BooleanClause(q, occur);
 }
Exemplo n.º 34
0
		/// <summary>Constructs a BooleanClause.</summary>
		public BooleanClause(Query query, Occur occur)
		{
			this.query = query;
			this.occur = occur;
		}
Exemplo n.º 35
0
		public virtual void  SetOccur(Occur occur)
		{
			this.occur = occur;
		}
Exemplo n.º 36
0
 /// <summary> Parses a query, searching on the fields specified. Use this if you need
 /// to specify certain fields as required, and others as prohibited.
 /// <p/>
 /// Usage:
 /// <code>
 /// String[] query = {&quot;query1&quot;, &quot;query2&quot;, &quot;query3&quot;};
 /// String[] fields = {&quot;filename&quot;, &quot;contents&quot;, &quot;description&quot;};
 /// BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
 /// BooleanClause.Occur.MUST,
 /// BooleanClause.Occur.MUST_NOT};
 /// MultiFieldQueryParser.parse(query, fields, flags, analyzer);
 /// </code>
 /// <p/>
 /// The code above would construct a query:
 /// 
 /// <code>
 /// (filename:query1) +(contents:query2) -(description:query3)
 /// </code>
 /// 
 /// </summary>
 /// <param name="matchVersion">Lucene version to match; this is passed through to
 /// QueryParser.
 /// </param>
 /// <param name="queries">Queries string to parse
 /// </param>
 /// <param name="fields">Fields to search on
 /// </param>
 /// <param name="flags">Flags describing the fields
 /// </param>
 /// <param name="analyzer">Analyzer to use
 /// </param>
 /// <throws>  ParseException </throws>
 /// <summary>             if query parsing fails
 /// </summary>
 /// <throws>  IllegalArgumentException </throws>
 /// <summary>             if the length of the queries, fields, and flags array differ
 /// </summary>
 public static Query Parse(Version matchVersion, System.String[] queries, System.String[] fields, Occur[] flags, Analyzer analyzer)
 {
     if (!(queries.Length == fields.Length && queries.Length == flags.Length))
         throw new System.ArgumentException("queries, fields, and flags array have have different length");
     BooleanQuery bQuery = new BooleanQuery();
     for (int i = 0; i < fields.Length; i++)
     {
         QueryParser qp = new QueryParser(matchVersion, fields[i], analyzer);
         Query q = qp.Parse(queries[i]);
         if (q != null && (!(q is BooleanQuery) || ((BooleanQuery)q).GetClauses().Length > 0))
         {
             bQuery.Add(q, flags[i]);
         }
     }
     return bQuery;
 }