Exemplo n.º 1
0
        public override Query Rewrite(IndexReader reader)
        {
            SpanOrQuery clone = null;

            for (int i = 0; i < clauses.Count; i++)
            {
                SpanQuery c     = clauses[i];
                SpanQuery query = (SpanQuery)c.Rewrite(reader);
                if (query != c) // clause rewrote: must clone
                {
                    if (clone == null)
                    {
                        clone = (SpanOrQuery)this.Clone();
                    }
                    clone.clauses[i] = query;
                }
            }
            if (clone != null)
            {
                return(clone); // some clauses rewrote
            }
            else
            {
                return(this); // no clauses rewrote
            }
        }
Exemplo n.º 2
0
        public override Query Rewrite(IndexReader reader)
        {
            SpanNotQuery clone = null;

            var rewrittenInclude = (SpanQuery)include.Rewrite(reader);

            if (rewrittenInclude != include)
            {
                clone         = (SpanNotQuery)this.Clone();
                clone.include = rewrittenInclude;
            }
            var rewrittenExclude = (SpanQuery)exclude.Rewrite(reader);

            if (rewrittenExclude != exclude)
            {
                if (clone == null)
                {
                    clone = (SpanNotQuery)this.Clone();
                }
                clone.exclude = rewrittenExclude;
            }

            if (clone != null)
            {
                return(clone); // some clauses rewrote
            }
            else
            {
                return(this); // no clauses rewrote
            }
        }
        public override Query Rewrite(IndexReader reader)
        {
            FieldMaskingSpanQuery clone = null;

            SpanQuery rewritten = (SpanQuery)maskedQuery.Rewrite(reader);

            if (rewritten != maskedQuery)
            {
                clone             = (FieldMaskingSpanQuery)this.Clone();
                clone.maskedQuery = rewritten;
            }

            if (clone != null)
            {
                return(clone);
            }
            else
            {
                return(this);
            }
        }