/// <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);
        }
 /// <summary> Creates a MultiFieldQueryParser. Allows passing of a map with term to
 /// Boost, and the boost to apply to each term.
 /// 
 /// <p/>
 /// It will, when parse(String query) is called, construct a query like this
 /// (assuming the query consists of two terms and you specify the two fields
 /// <c>title</c> and <c>body</c>):
 /// <p/>
 /// 
 /// <code>
 /// (title:term1 body:term1) (title:term2 body:term2)
 /// </code>
 /// 
 /// <p/>
 /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
 /// <p/>
 /// 
 /// <code>
 /// +(title:term1 body:term1) +(title:term2 body:term2)
 /// </code>
 /// 
 /// <p/>
 /// When you pass a boost (title=>5 body=>10) you can get
 /// <p/>
 /// 
 /// <code>
 /// +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
 /// </code>
 /// 
 /// <p/>
 /// In other words, all the query's terms must appear, but it doesn't matter
 /// in what fields they appear.
 /// <p/>
 /// </summary>
 public MultiFieldQueryParser(Version matchVersion, string[] fields, Analyzer analyzer, IDictionary<string, float> boosts)
     : this(matchVersion, fields, analyzer)
 {
     this.boosts = boosts;
 }
 /// <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;
 }
 /// <summary> Creates a MultiFieldQueryParser.
 /// 
 /// <p/>
 /// It will, when parse(String query) is called, construct a query like this
 /// (assuming the query consists of two terms and you specify the two fields
 /// <c>title</c> and <c>body</c>):
 /// <p/>
 /// 
 /// <code>
 /// (title:term1 body:term1) (title:term2 body:term2)
 /// </code>
 /// 
 /// <p/>
 /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
 /// <p/>
 /// 
 /// <code>
 /// +(title:term1 body:term1) +(title:term2 body:term2)
 /// </code>
 /// 
 /// <p/>
 /// In other words, all the query's terms must appear, but it doesn't matter
 /// in what fields they appear.
 /// <p/>
 /// </summary>
 public MultiFieldQueryParser(Version matchVersion, System.String[] fields, Analyzer analyzer)
     : base(matchVersion, null, analyzer)
 {
     this.fields = fields;
 }
 /// <summary> Creates a MultiFieldQueryParser. Allows passing of a map with term to
 /// Boost, and the boost to apply to each term.
 ///
 /// <p/>
 /// It will, when parse(String query) is called, construct a query like this
 /// (assuming the query consists of two terms and you specify the two fields
 /// <c>title</c> and <c>body</c>):
 /// <p/>
 ///
 /// <code>
 /// (title:term1 body:term1) (title:term2 body:term2)
 /// </code>
 ///
 /// <p/>
 /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
 /// <p/>
 ///
 /// <code>
 /// +(title:term1 body:term1) +(title:term2 body:term2)
 /// </code>
 ///
 /// <p/>
 /// When you pass a boost (title=>5 body=>10) you can get
 /// <p/>
 ///
 /// <code>
 /// +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
 /// </code>
 ///
 /// <p/>
 /// In other words, all the query's terms must appear, but it doesn't matter
 /// in what fields they appear.
 /// <p/>
 /// </summary>
 public MultiFieldQueryParser(Version matchVersion, string[] fields, Analyzer analyzer, IDictionary <string, float> boosts)
     : this(matchVersion, fields, analyzer)
 {
     this.boosts = boosts;
 }
 /// <summary> Creates a MultiFieldQueryParser.
 ///
 /// <p/>
 /// It will, when parse(String query) is called, construct a query like this
 /// (assuming the query consists of two terms and you specify the two fields
 /// <c>title</c> and <c>body</c>):
 /// <p/>
 ///
 /// <code>
 /// (title:term1 body:term1) (title:term2 body:term2)
 /// </code>
 ///
 /// <p/>
 /// When setDefaultOperator(AND_OPERATOR) is set, the result will be:
 /// <p/>
 ///
 /// <code>
 /// +(title:term1 body:term1) +(title:term2 body:term2)
 /// </code>
 ///
 /// <p/>
 /// In other words, all the query's terms must appear, but it doesn't matter
 /// in what fields they appear.
 /// <p/>
 /// </summary>
 public MultiFieldQueryParser(Version matchVersion, System.String[] fields, Analyzer analyzer)
     : base(matchVersion, null, analyzer)
 {
     this.fields = fields;
 }