public virtual Query Build(IQueryNode queryNode) { TermRangeQueryNode rangeNode = (TermRangeQueryNode)queryNode; FieldQueryNode upper = (FieldQueryNode)rangeNode.UpperBound; FieldQueryNode lower = (FieldQueryNode)rangeNode.LowerBound; string field = StringUtils.ToString(rangeNode.Field); string lowerText = lower.GetTextAsString(); string upperText = upper.GetTextAsString(); if (lowerText.Length == 0) { lowerText = null; } if (upperText.Length == 0) { upperText = null; } TermRangeQuery rangeQuery = TermRangeQuery.NewStringRange(field, lowerText, upperText, rangeNode .IsLowerInclusive, rangeNode.IsUpperInclusive); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode .GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { rangeQuery.SetRewriteMethod(method); } return rangeQuery; }
public virtual Query Build(IQueryNode queryNode) { TermRangeQueryNode rangeNode = (TermRangeQueryNode)queryNode; FieldQueryNode upper = (FieldQueryNode)rangeNode.UpperBound; FieldQueryNode lower = (FieldQueryNode)rangeNode.LowerBound; string field = StringUtils.ToString(rangeNode.Field); string lowerText = lower.GetTextAsString(); string upperText = upper.GetTextAsString(); if (lowerText.Length == 0) { lowerText = null; } if (upperText.Length == 0) { upperText = null; } TermRangeQuery rangeQuery = TermRangeQuery.NewStringRange(field, lowerText, upperText, rangeNode .IsLowerInclusive, rangeNode.IsUpperInclusive); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode .GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { rangeQuery.MultiTermRewriteMethod = method; } return(rangeQuery); }
public virtual Query Build(IQueryNode queryNode) { PrefixWildcardQueryNode wildcardNode = (PrefixWildcardQueryNode)queryNode; string text = wildcardNode.Text.SubSequence(0, wildcardNode.Text.Length - 1).ToString(); PrefixQuery q = new PrefixQuery(new Term(wildcardNode.GetFieldAsString(), text)); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.MultiTermRewriteMethod = method; } return(q); }
public virtual Query Build(IQueryNode queryNode) { WildcardQueryNode wildcardNode = (WildcardQueryNode)queryNode; WildcardQuery q = new WildcardQuery(new Term(wildcardNode.GetFieldAsString(), wildcardNode.GetTextAsString())); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.SetRewriteMethod(method); } return q; }
public virtual Query Build(IQueryNode queryNode) { WildcardQueryNode wildcardNode = (WildcardQueryNode)queryNode; WildcardQuery q = new WildcardQuery(new Term(wildcardNode.GetFieldAsString(), wildcardNode.GetTextAsString())); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.MultiTermRewriteMethod = method; } return(q); }
public virtual Query Build(IQueryNode queryNode) { PrefixWildcardQueryNode wildcardNode = (PrefixWildcardQueryNode)queryNode; string text = wildcardNode.Text.SubSequence(0, wildcardNode.Text.Length - 1).ToString(); PrefixQuery q = new PrefixQuery(new Term(wildcardNode.GetFieldAsString(), text)); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode.GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.SetRewriteMethod(method); } return q; }
public virtual Query Build(IQueryNode queryNode) { RegexpQueryNode regexpNode = (RegexpQueryNode)queryNode; RegexpQuery q = new RegexpQuery(new Term(regexpNode.GetFieldAsString(), regexpNode.TextToBytesRef())); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode .GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.SetRewriteMethod(method); } return q; }
public virtual Query Build(IQueryNode queryNode) { RegexpQueryNode regexpNode = (RegexpQueryNode)queryNode; RegexpQuery q = new RegexpQuery(new Term(regexpNode.GetFieldAsString(), regexpNode.TextToBytesRef())); MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode .GetTag(MultiTermRewriteMethodProcessor.TAG_ID); if (method != null) { q.MultiTermRewriteMethod = method; } return(q); }
public virtual Query Build(IQueryNode queryNode) { BoostQueryNode boostNode = (BoostQueryNode)queryNode; IQueryNode child = boostNode.Child; if (child is null) { return(null); } Query query = (Query)child .GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); query.Boost = boostNode.Value; return(query); }
/// <summary> /// Builds some kind of object from a query tree. Each node in the query tree /// is built using an specific builder associated to it. /// </summary> /// <param name="queryNode">the query tree root node</param> /// <returns>the built object</returns> /// <exception cref="QueryNodeException">if some node builder throws a /// <see cref="QueryNodeException"/> or if there is a node which had no /// builder associated to it</exception> public virtual TQuery Build(IQueryNode queryNode) { Process(queryNode); return((TQuery)queryNode.GetTag(QUERY_TREE_BUILDER_TAGID)); }