Exemplo n.º 1
0
        /// <summary>
        /// Constructor for serialization of inheritor classes.
        /// </summary>
        /// <param name="matchType"></param>
        protected MatchQueryBase(MatchQueryTypeEnum matchType):this()
        {
            if (matchType == null)
                throw new ArgumentNullException("matchType", "The type of match query must be specified.");

            _Type = matchType;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for multi_match queries.
        /// </summary>
        /// <param name="matchType"></param>
        /// <param name="query"></param>
        protected MatchQueryBase(MatchQueryTypeEnum matchType, string query):this()
        {
            if (matchType == null)
                throw new ArgumentNullException("matchType", "The type of match query must be specified.");
            if (matchType != MatchQueryTypeEnum.Multi)
                throw new ArgumentOutOfRangeException("matchType", "Non multi_match queries must use the constructor with a field parameter.");
            if (string.IsNullOrWhiteSpace(query))
                throw new ArgumentNullException("query", "The query must be populated.");

            _Type = matchType;
            Query = query;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor for boolean, phrase, and phrase prefix match types.
        /// </summary>
        /// <param name="matchType">The type of match query to use. Do not use multi_match in this constructor.</param>
        /// <param name="field">The field to search in.</param>
        /// <param name="query">The values to search for in the field.</param>
        protected MatchQueryBase(MatchQueryTypeEnum matchType, string field, string query):this()
        {
            if (matchType == null)
                throw new ArgumentNullException("matchType", "The type of match query must be specified.");
            if(matchType == MatchQueryTypeEnum.Multi)
                throw new ArgumentOutOfRangeException("matchType", "The multi_match query must use the constructor allowing multiple fields.");
            if (string.IsNullOrWhiteSpace(field))
                throw new ArgumentNullException("field", "The field to query against must be specified.");
            if (string.IsNullOrWhiteSpace(query))
                throw new ArgumentNullException("query", "The query must be populated.");

            _Type = matchType;
            Field = field;
            Query = query;
        }