예제 #1
0
        /// <summary>Adds a clause to a boolean query.</summary>
        /// <throws>  TooManyClauses if the new number of clauses exceeds the maximum clause number </throws>
        /// <seealso cref="GetMaxClauseCount()">
        /// </seealso>
        public virtual void  Add(BooleanClause clause)
        {
            if (clauses.Count >= maxClauseCount)
            {
                throw new TooManyClauses();
            }

            clauses.Add(clause);
        }
예제 #2
0
        /// <summary> Adds a term to the end of the query phrase.
        /// The relative position of the term within the phrase is specified explicitly.
        /// This allows e.g. phrases with more than one term at the same position
        /// or phrases with gaps (e.g. in connection with stopwords).
        ///
        /// </summary>
        /// <param name="term">
        /// </param>
        /// <param name="position">
        /// </param>
        public virtual void  Add(Term term, int position)
        {
            if (terms.Count == 0)
            {
                field = term.Field();
            }
            else if (term.Field() != field)
            {
                throw new System.ArgumentException("All phrase terms must be in the same field: " + term);
            }

            terms.Add(term);
            positions.Add((System.Int32)position);
            if (position > maxPosition)
            {
                maxPosition = position;
            }
        }
예제 #3
0
 /// <summary>Add a subquery to this disjunction</summary>
 /// <param name="query">the disjunct added
 /// </param>
 public virtual void  Add(Query query)
 {
     disjuncts.Add(query);
 }