protected override IQueryNode PostProcessNode(IQueryNode node) { // the old Lucene Parser ignores FuzzyQueryNode that are also PrefixWildcardQueryNode or WildcardQueryNode // we do the same here, also ignore empty terms if (node is FieldQueryNode || node is FuzzyQueryNode) { FieldQueryNode fqn = (FieldQueryNode)node; string text = fqn.Text.ToString(); // do not process wildcards for TermRangeQueryNode children and // QuotedFieldQueryNode to reproduce the old parser behavior if (fqn.Parent is TermRangeQueryNode || fqn is QuotedFieldQueryNode || text.Length <= 0) { // Ignore empty terms return node; } // Code below simulates the old lucene parser behavior for wildcards if (IsPrefixWildcard(text)) { PrefixWildcardQueryNode prefixWildcardQN = new PrefixWildcardQueryNode(fqn); return prefixWildcardQN; } else if (IsWildcard(text)) { WildcardQueryNode wildcardQN = new WildcardQueryNode(fqn); return wildcardQN; } } return node; }
public override IQueryNode CloneTree() { WildcardQueryNode clone = (WildcardQueryNode)base.CloneTree(); // nothing to do here return(clone); }