Example #1
0
        protected virtual IQueryNode PreProcessNode(IQueryNode node)
        {
            IQueryNode parent = node.Parent;

            if (node is BooleanQueryNode)
            {
                if (parent is BooleanQueryNode)
                {
                    node.SetTag(TAG_REMOVE, true); // no precedence
                }
                else
                {
                    node.SetTag(TAG_BOOLEAN_ROOT, true);
                }
            }
            else if (parent is BooleanQueryNode)
            {
                if ((parent is AndQueryNode) ||
                    (usingAnd && IsDefaultBooleanQueryNode(parent)))
                {
                    TagModifierButDoNotOverride(node, Modifier.MOD_REQ);
                }
            }
            return(node);
        }
 protected virtual void TagModifierButDoNotOverride(IQueryNode node, Modifier mod)
 {
     if (node is ModifierQueryNode)
     {
         ModifierQueryNode modNode = (ModifierQueryNode)node;
         if (modNode.Modifier == Modifier.MOD_NONE)
         {
             node.SetTag(TAG_MODIFIER, mod);
         }
     }
     else
     {
         node.SetTag(TAG_MODIFIER, Modifier.MOD_REQ);
     }
 }
Example #3
0
        private void ProcessNode(IQueryNode node, IQueryBuilder <TQuery> builder)
        {
            if (builder == null)
            {
                throw new QueryNodeException(new Message(
                                                 QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, node
                                                 .ToQueryString(new EscapeQuerySyntax()), node.GetType()
                                                 .Name));
            }

            object obj = builder.Build(node);

            if (obj != null)
            {
                node.SetTag(QUERY_TREE_BUILDER_TAGID, obj);
            }
        }
Example #4
0
        private static void ProcessNode(IQueryNode node, IQueryBuilder <TQuery> builder) // LUCENENET: CA1822: Mark members as static
        {
            if (builder == null)
            {
                // LUCENENET: Factored out NLS/Message/IMessage so end users can optionally utilize the built-in .NET localization.
                throw new QueryNodeException(string.Format(
                                                 QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, node
                                                 .ToQueryString(new EscapeQuerySyntax()), node.GetType()
                                                 .Name));
            }

            object obj = builder.Build(node);

            if (obj != null)
            {
                node.SetTag(QUERY_TREE_BUILDER_TAGID, obj);
            }
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            // set setMultiTermRewriteMethod for WildcardQueryNode and
            // PrefixWildcardQueryNode
            if (node is WildcardQueryNode ||
                node is IAbstractRangeQueryNode || node is RegexpQueryNode)
            {
                MultiTermQuery.RewriteMethod rewriteMethod = GetQueryConfigHandler().Get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);

                if (rewriteMethod == null)
                {
                    // This should not happen, this configuration is set in the
                    // StandardQueryConfigHandler
                    throw new ArgumentException(
                              "StandardQueryConfigHandler.ConfigurationKeys.MULTI_TERM_REWRITE_METHOD should be set on the QueryConfigHandler");
                }

                // use a TAG to take the value to the Builder
                node.SetTag(MultiTermRewriteMethodProcessor.TAG_ID, rewriteMethod);
            }

            return(node);
        }
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            // set setMultiTermRewriteMethod for WildcardQueryNode and
            // PrefixWildcardQueryNode
            if (node is WildcardQueryNode
                || node is IAbstractRangeQueryNode || node is RegexpQueryNode)
            {
                MultiTermQuery.RewriteMethod rewriteMethod = GetQueryConfigHandler().Get(ConfigurationKeys.MULTI_TERM_REWRITE_METHOD);

                if (rewriteMethod == null)
                {
                    // This should not happen, this configuration is set in the
                    // StandardQueryConfigHandler
                    throw new ArgumentException(
                        "StandardQueryConfigHandler.ConfigurationKeys.MULTI_TERM_REWRITE_METHOD should be set on the QueryConfigHandler");
                }

                // use a TAG to take the value to the Builder
                node.SetTag(MultiTermRewriteMethodProcessor.TAG_ID, rewriteMethod);
            }

            return node;
        }
 protected virtual void TagModifierButDoNotOverride(IQueryNode node, Modifier mod)
 {
     if (node is ModifierQueryNode)
     {
         ModifierQueryNode modNode = (ModifierQueryNode)node;
         if (modNode.Modifier == Modifier.MOD_NONE)
         {
             node.SetTag(TAG_MODIFIER, mod);
         }
     }
     else
     {
         node.SetTag(TAG_MODIFIER, Modifier.MOD_REQ);
     }
 }
 protected virtual IQueryNode PreProcessNode(IQueryNode node)
 {
     IQueryNode parent = node.Parent;
     if (node is BooleanQueryNode)
     {
         if (parent is BooleanQueryNode)
         {
             node.SetTag(TAG_REMOVE, true); // no precedence
         }
         else
         {
             node.SetTag(TAG_BOOLEAN_ROOT, true);
         }
     }
     else if (parent is BooleanQueryNode)
     {
         if ((parent is AndQueryNode)
             || (usingAnd && IsDefaultBooleanQueryNode(parent)))
         {
             TagModifierButDoNotOverride(node, Modifier.MOD_REQ);
         }
     }
     return node;
 }