Esempio n. 1
0
        public override Query VisitTermRangeQuery(TermRangeQuery termRangeq)
        {
            var field = termRangeq.GetField();
            var lowerTerm = GetTermText(termRangeq.GetLowerTerm());
            var upperTerm = GetTermText(termRangeq.GetUpperTerm());
            var includesLower = termRangeq.IncludesLower();
            var includesUpper = termRangeq.IncludesUpper();
            string oneTerm = null;

            _text.Append(field);
            _text.Append(":");

            string op = null;
            if (lowerTerm == null)
            {
                op = includesUpper ? "<=" : "<";
                oneTerm = upperTerm;
            }
            if (upperTerm == null)
            {
                op = includesLower ? ">=" : ">";
                oneTerm = lowerTerm;
            }

            if (op == null)
            {
                _text.Append(includesLower ? '[' : '{');
                _text.Append(lowerTerm);
                _text.Append(" TO ");
                _text.Append(upperTerm);
                _text.Append(includesUpper ? ']' : '}');
            }
            else
            {
                _text.Append(op).Append(oneTerm);
            }

            _text.Append(BoostToString(termRangeq.GetBoost()));

            return base.VisitTermRangeQuery(termRangeq);
        }