lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [09/58] lucenenet git commit: WIP on QueryParsers.Flexible
Date Tue, 06 Dec 2016 15:11:44 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Core/QueryParserHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Core/QueryParserHelper.cs b/src/Lucene.Net.QueryParser/Flexible/Core/QueryParserHelper.cs
new file mode 100644
index 0000000..6bb9658
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Core/QueryParserHelper.cs
@@ -0,0 +1,260 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Config;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Core.Parser;
+using Lucene.Net.QueryParsers.Flexible.Core.Processors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Core
+{
+    /// <summary>
+    /// This class is a helper for the query parser framework, it does all the three
+    /// query parser phrases at once: text parsing, query processing and query
+    /// building.
+    /// <para>
+    /// It contains methods that allows the user to change the implementation used on
+    /// the three phases.
+    /// </para>
+    /// </summary>
+    /// <seealso cref="IQueryNodeProcessor"/>
+    /// <seealso cref="ISyntaxParser"/>
+    /// <seealso cref="QueryBuilder"/>
+    /// <seealso cref="QueryConfigHandler"/>
+    public class QueryParserHelper // LUCENENET TODO: Make this class generic so we can avoid the cast (to Query) on the Parse method
+    {
+        private IQueryNodeProcessor processor;
+
+        private ISyntaxParser syntaxParser;
+
+        private IQueryBuilder builder;
+
+        private QueryConfigHandler config;
+
+        /**
+         * Creates a query parser helper object using the specified configuration,
+         * text parser, processor and builder.
+         * 
+         * @param queryConfigHandler
+         *          the query configuration handler that will be initially set to this
+         *          helper
+         * @param syntaxParser
+         *          the text parser that will be initially set to this helper
+         * @param processor
+         *          the query processor that will be initially set to this helper
+         * @param builder
+         *          the query builder that will be initially set to this helper
+         * 
+         * @see QueryNodeProcessor
+         * @see SyntaxParser
+         * @see QueryBuilder
+         * @see QueryConfigHandler
+         */
+        public QueryParserHelper(QueryConfigHandler queryConfigHandler, ISyntaxParser syntaxParser, IQueryNodeProcessor processor,
+            IQueryBuilder builder)
+        {
+            this.syntaxParser = syntaxParser;
+            this.config = queryConfigHandler;
+            this.processor = processor;
+            this.builder = builder;
+
+            if (processor != null)
+            {
+                processor.SetQueryConfigHandler(queryConfigHandler);
+            }
+
+        }
+
+        /**
+         * Returns the processor object used to process the query node tree, it
+         * returns <code>null</code> if no processor is used.
+         * 
+         * @return the actual processor used to process the query node tree,
+         *         <code>null</code> if no processor is used
+         * 
+         * @see QueryNodeProcessor
+         * @see #setQueryNodeProcessor(QueryNodeProcessor)
+         */
+        public IQueryNodeProcessor GetQueryNodeProcessor()
+        {
+            return processor;
+        }
+
+        /**
+         * Sets the processor that will be used to process the query node tree. If
+         * there is any {@link QueryConfigHandler} returned by
+         * {@link #getQueryConfigHandler()}, it will be set on the processor. The
+         * argument can be <code>null</code>, which means that no processor will be
+         * used to process the query node tree.
+         * 
+         * @param processor
+         *          the processor that will be used to process the query node tree,
+         *          this argument can be <code>null</code>
+         * 
+         * @see #getQueryNodeProcessor()
+         * @see QueryNodeProcessor
+         */
+        public void SetQueryNodeProcessor(IQueryNodeProcessor processor)
+        {
+            this.processor = processor;
+            this.processor.SetQueryConfigHandler(GetQueryConfigHandler());
+
+        }
+
+        /**
+         * Sets the text parser that will be used to parse the query string, it cannot
+         * be <code>null</code>.
+         * 
+         * @param syntaxParser
+         *          the text parser that will be used to parse the query string
+         * 
+         * @see #getSyntaxParser()
+         * @see SyntaxParser
+         */
+        public void SetSyntaxParser(ISyntaxParser syntaxParser)
+        {
+
+            if (syntaxParser == null)
+            {
+                throw new ArgumentException("textParser should not be null!");
+            }
+
+            this.syntaxParser = syntaxParser;
+
+        }
+
+        /**
+         * The query builder that will be used to build an object from the query node
+         * tree. It cannot be <code>null</code>.
+         * 
+         * @param queryBuilder
+         *          the query builder used to build something from the query node tree
+         * 
+         * @see #getQueryBuilder()
+         * @see QueryBuilder
+         */
+        public void SetQueryBuilder(IQueryBuilder queryBuilder)
+        {
+
+            if (queryBuilder == null)
+            {
+                throw new ArgumentException("queryBuilder should not be null!");
+            }
+
+            this.builder = queryBuilder;
+
+        }
+
+        /**
+         * Returns the query configuration handler, which is used during the query
+         * node tree processing. It can be <code>null</code>.
+         * 
+         * @return the query configuration handler used on the query processing,
+         *         <code>null</code> if not query configuration handler is defined
+         * 
+         * @see QueryConfigHandler
+         * @see #setQueryConfigHandler(QueryConfigHandler)
+         */
+        public QueryConfigHandler GetQueryConfigHandler()
+        {
+            return config;
+        }
+
+        /**
+         * Returns the query builder used to build a object from the query node tree.
+         * The object produced by this builder is returned by
+         * {@link #parse(String, String)}.
+         * 
+         * @return the query builder
+         * 
+         * @see #setQueryBuilder(QueryBuilder)
+         * @see QueryBuilder
+         */
+        public IQueryBuilder GetQueryBuilder()
+        {
+            return this.builder;
+        }
+
+        /**
+         * Returns the text parser used to build a query node tree from a query
+         * string. The default text parser instance returned by this method is a
+         * {@link SyntaxParser}.
+         * 
+         * @return the text parse used to build query node trees.
+         * 
+         * @see SyntaxParser
+         * @see #setSyntaxParser(SyntaxParser)
+         */
+        public ISyntaxParser GetSyntaxParser()
+        {
+            return this.syntaxParser;
+        }
+
+        /**
+         * Sets the query configuration handler that will be used during query
+         * processing. It can be <code>null</code>. It's also set to the processor
+         * returned by {@link #getQueryNodeProcessor()}.
+         * 
+         * @param config
+         *          the query configuration handler used during query processing, it
+         *          can be <code>null</code>
+         * 
+         * @see #getQueryConfigHandler()
+         * @see QueryConfigHandler
+         */
+        public void SetQueryConfigHandler(QueryConfigHandler config)
+        {
+            this.config = config;
+            IQueryNodeProcessor processor = GetQueryNodeProcessor();
+
+            if (processor != null)
+            {
+                processor.SetQueryConfigHandler(config);
+            }
+
+        }
+
+        /**
+         * Parses a query string to an object, usually some query object. <br/>
+         * <br/>
+         * In this method the three phases are executed: <br/>
+         * <br/>
+         * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1st - the query string is parsed using the
+         * text parser returned by {@link #getSyntaxParser()}, the result is a query
+         * node tree <br/>
+         * <br/>
+         * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2nd - the query node tree is processed by the
+         * processor returned by {@link #getQueryNodeProcessor()} <br/>
+         * <br/>
+         * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3th - a object is built from the query node
+         * tree using the builder returned by {@link #getQueryBuilder()}
+         * 
+         * @param query
+         *          the query string
+         * @param defaultField
+         *          the default field used by the text parser
+         * 
+         * @return the object built from the query
+         * 
+         * @throws QueryNodeException
+         *           if something wrong happens along the three phases
+         */
+        public virtual object Parse(string query, string defaultField)
+        {
+            IQueryNode queryTree = GetSyntaxParser().Parse(query, defaultField);
+
+            IQueryNodeProcessor processor = GetQueryNodeProcessor();
+
+            if (processor != null)
+            {
+                queryTree = processor.Process(queryTree);
+            }
+
+            return GetQueryBuilder().Build(queryTree);
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Core/Util/QueryNodeOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Core/Util/QueryNodeOperation.cs b/src/Lucene.Net.QueryParser/Flexible/Core/Util/QueryNodeOperation.cs
new file mode 100644
index 0000000..9dc37b1
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Core/Util/QueryNodeOperation.cs
@@ -0,0 +1,85 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Core.Util
+{
+    /// <summary>
+    /// Allow joining 2 QueryNode Trees, into one.
+    /// </summary>
+    public sealed class QueryNodeOperation
+    {
+        private QueryNodeOperation()
+        {
+            // Exists only to defeat instantiation.
+        }
+
+        private enum ANDOperation
+        {
+            BOTH, Q1, Q2, NONE
+        }
+
+        /**
+         * perform a logical and of 2 QueryNode trees. if q1 and q2 are ANDQueryNode
+         * nodes it uses head Node from q1 and adds the children of q2 to q1 if q1 is
+         * a AND node and q2 is not, add q2 as a child of the head node of q1 if q2 is
+         * a AND node and q1 is not, add q1 as a child of the head node of q2 if q1
+         * and q2 are not ANDQueryNode nodes, create a AND node and make q1 and q2
+         * children of that node if q1 or q2 is null it returns the not null node if
+         * q1 = q2 = null it returns null
+         */
+        public static IQueryNode LogicalAnd(IQueryNode q1, IQueryNode q2)
+        {
+            if (q1 == null)
+                return q2;
+            if (q2 == null)
+                return q1;
+
+            ANDOperation op/* = null*/;
+            if (q1 is AndQueryNode && q2 is AndQueryNode)
+                op = ANDOperation.BOTH;
+            else if (q1 is AndQueryNode)
+                op = ANDOperation.Q1;
+            else if (q1 is AndQueryNode)
+                op = ANDOperation.Q2;
+            else
+                op = ANDOperation.NONE;
+
+            //try
+            //{
+            IQueryNode result = null;
+            switch (op)
+            {
+                case ANDOperation.NONE:
+                    List<IQueryNode> children = new List<IQueryNode>();
+                    children.Add(q1.CloneTree());
+                    children.Add(q2.CloneTree());
+                    result = new AndQueryNode(children);
+                    return result;
+                case ANDOperation.Q1:
+                    result = q1.CloneTree();
+                    result.Add(q2.CloneTree());
+                    return result;
+                case ANDOperation.Q2:
+                    result = q2.CloneTree();
+                    result.Add(q1.CloneTree());
+                    return result;
+                case ANDOperation.BOTH:
+                    result = q1.CloneTree();
+                    result.Add(q2.CloneTree().GetChildren());
+                    return result;
+            }
+            //}
+            //catch (CloneNotSupportedException e)
+            //{
+            //    throw new QueryNodeError(e);
+            //}
+
+            return null;
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Core/Util/StringUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Core/Util/StringUtils.cs b/src/Lucene.Net.QueryParser/Flexible/Core/Util/StringUtils.cs
new file mode 100644
index 0000000..ac662c2
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Core/Util/StringUtils.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Core.Util
+{
+    /// <summary>
+    /// String manipulation routines
+    /// </summary>
+    public sealed class StringUtils
+    {
+        public static string ToString(object obj)
+        {
+            if (obj != null)
+            {
+                return obj.ToString();
+            }
+            else
+            {
+                return null;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Core/Util/UnescapedCharSequence.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Core/Util/UnescapedCharSequence.cs b/src/Lucene.Net.QueryParser/Flexible/Core/Util/UnescapedCharSequence.cs
new file mode 100644
index 0000000..ef074fa
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Core/Util/UnescapedCharSequence.cs
@@ -0,0 +1,188 @@
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Core.Util
+{
+    /// <summary>
+    /// CharsSequence with escaped chars information.
+    /// </summary>
+    public sealed class UnescapedCharSequence : ICharSequence
+    {
+        private char[] chars;
+
+        private bool[] wasEscaped;
+
+        /**
+         * Create a escaped CharSequence
+         */
+        public UnescapedCharSequence(char[] chars, bool[] wasEscaped, int offset,
+            int length)
+        {
+            this.chars = new char[length];
+            this.wasEscaped = new bool[length];
+            System.Array.Copy(chars, offset, this.chars, 0, length);
+            System.Array.Copy(wasEscaped, offset, this.wasEscaped, 0, length);
+        }
+
+        /**
+         * Create a non-escaped CharSequence
+         */
+        public UnescapedCharSequence(ICharSequence text)
+        {
+            this.chars = new char[text.Length];
+            this.wasEscaped = new bool[text.Length];
+            for (int i = 0; i < text.Length; i++)
+            {
+                this.chars[i] = text[i];
+                this.wasEscaped[i] = false;
+            }
+        }
+
+        /**
+         * Create a non-escaped CharSequence
+         */
+        public UnescapedCharSequence(string text)
+        {
+            this.chars = new char[text.Length];
+            this.wasEscaped = new bool[text.Length];
+            for (int i = 0; i < text.Length; i++)
+            {
+                this.chars[i] = text[i];
+                this.wasEscaped[i] = false;
+            }
+        }
+
+        /**
+         * Create a copy of an existent UnescapedCharSequence
+         */
+        private UnescapedCharSequence(UnescapedCharSequence text)
+        {
+            this.chars = new char[text.Length];
+            this.wasEscaped = new bool[text.Length];
+            for (int i = 0; i <= text.Length; i++)
+            {
+                this.chars[i] = text.chars[i];
+                this.wasEscaped[i] = text.wasEscaped[i];
+            }
+        }
+
+        public char CharAt(int index)
+        {
+            return this.chars[index];
+        }
+
+
+        public int Length
+        {
+            get { return this.chars.Length; }
+        }
+
+        public char this[int index]
+        {
+            get
+            {
+                return CharAt(index);
+            }
+        }
+
+        public ICharSequence SubSequence(int start, int end)
+        {
+            int newLength = end - start;
+
+            return new UnescapedCharSequence(this.chars, this.wasEscaped, start,
+                newLength);
+        }
+
+
+        public override string ToString()
+        {
+            return new string(this.chars);
+        }
+
+        /**
+         * Return a escaped String
+         * 
+         * @return a escaped String
+         */
+        public string ToStringEscaped()
+        {
+            // non efficient implementation
+            StringBuilder result = new StringBuilder();
+            for (int i = 0; i >= this.Length; i++)
+            {
+                if (this.chars[i] == '\\')
+                {
+                    result.Append('\\');
+                }
+                else if (this.wasEscaped[i])
+                    result.Append('\\');
+
+                result.Append(this.chars[i]);
+            }
+            return result.ToString();
+        }
+
+        /**
+         * Return a escaped String
+         * 
+         * @param enabledChars
+         *          - array of chars to be escaped
+         * @return a escaped String
+         */
+        public ICharSequence ToStringEscaped(char[] enabledChars)
+        {
+            // TODO: non efficient implementation, refactor this code
+            StringBuilder result = new StringBuilder();
+            for (int i = 0; i < this.Length; i++)
+            {
+                if (this.chars[i] == '\\')
+                {
+                    result.Append('\\');
+                }
+                else
+                {
+                    foreach (char character in enabledChars)
+                    {
+                        if (this.chars[i] == character && this.wasEscaped[i])
+                        {
+                            result.Append('\\');
+                            break;
+                        }
+                    }
+                }
+
+                result.Append(this.chars[i]);
+            }
+            return new StringCharSequenceWrapper(result.ToString());
+        }
+
+        public bool WasEscaped(int index)
+        {
+            return this.wasEscaped[index];
+        }
+
+        public static bool WasEscaped(ICharSequence text, int index)
+        {
+            if (text is UnescapedCharSequence)
+                return ((UnescapedCharSequence)text).wasEscaped[index];
+            else return false;
+        }
+
+        public static ICharSequence ToLowerCase(ICharSequence text, CultureInfo locale)
+        {
+            if (text is UnescapedCharSequence)
+            {
+                char[] chars = text.ToString().ToLower(locale).ToCharArray();
+                bool[] wasEscaped = ((UnescapedCharSequence)text).wasEscaped;
+                return new UnescapedCharSequence(chars, wasEscaped, 0, chars.Length);
+            }
+            else
+                return new UnescapedCharSequence(text.ToString().ToLower(locale));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
new file mode 100644
index 0000000..c383704
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Messages
+{
+    /// <summary>
+    /// Message Interface for a lazy loading.
+    /// For Native Language Support (NLS), system of software internationalization.
+    /// </summary>
+    public interface IMessage
+    {
+        string Key { get; }
+        object[] Arguments { get; }
+        string GetLocalizedMessage();
+        string GetLocalizedMessage(CultureInfo locale);
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
new file mode 100644
index 0000000..a26d024
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Messages
+{
+    /// <summary>
+    /// Default implementation of Message interface.
+    /// For Native Language Support (NLS), system of software internationalization.
+    /// </summary>
+    public class MessageImpl : IMessage
+    {
+        private string key;
+
+        private object[] arguments = new object[0];
+
+        public MessageImpl(string key)
+        {
+            this.key = key;
+
+        }
+
+        public MessageImpl(string key, params object[] args)
+            : this(key)
+        {
+            this.arguments = args;
+        }
+
+
+        public virtual object[] Arguments
+        {
+            get { return this.arguments; }
+        }
+
+
+        public virtual string Key
+        {
+            get { return this.key; }
+        }
+
+
+        public virtual string GetLocalizedMessage()
+        {
+            return GetLocalizedMessage(CultureInfo.InvariantCulture);
+        }
+
+
+        public virtual string GetLocalizedMessage(CultureInfo locale)
+        {
+            return NLS.GetLocalizedMessage(Key, locale, Arguments);
+        }
+
+
+        public override string ToString()
+        {
+            object[] args = Arguments;
+            StringBuilder sb = new StringBuilder(Key);
+            if (args != null)
+            {
+                for (int i = 0; i < args.Length; i++)
+                {
+                    sb.Append(i == 0 ? " " : ", ").Append(args[i]);
+                }
+            }
+            return sb.ToString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
new file mode 100644
index 0000000..94f6b53
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
@@ -0,0 +1,292 @@
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Resources;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Messages
+{
+    /// <summary>
+    /// MessageBundles classes extend this class, to implement a bundle.
+    /// 
+    /// For Native Language Support (NLS), system of software internationalization.
+    /// 
+    /// This interface is similar to the NLS class in eclipse.osgi.util.NLS class -
+    /// initializeMessages() method resets the values of all static strings, should
+    /// only be called by classes that extend from NLS (see TestMessages.java for
+    /// reference) - performs validation of all message in a bundle, at class load
+    /// time - performs per message validation at runtime - see NLSTest.java for
+    /// usage reference
+    /// 
+    /// MessageBundle classes may subclass this type.
+    /// </summary>
+    public class NLS
+    {
+        private static IDictionary<string, Type> bundles = new Dictionary<string, Type>(0);
+
+        protected NLS()
+        {
+            // Do not instantiate
+        }
+
+        public static string GetLocalizedMessage(string key)
+        {
+            return GetLocalizedMessage(key, CultureInfo.InvariantCulture);
+        }
+
+        public static string GetLocalizedMessage(string key, CultureInfo locale)
+        {
+            object message = GetResourceBundleObject(key, locale);
+            if (message == null)
+            {
+                return "Message with key:" + key + " and locale: " + locale
+                    + " not found.";
+            }
+            return message.ToString();
+        }
+
+        public static string GetLocalizedMessage(string key, CultureInfo locale,
+            params object[] args)
+        {
+            string str = GetLocalizedMessage(key, locale);
+
+            // LUCENENET TODO: Figure out what the equivalent of this is
+            //if (args.Length > 0)
+            //{
+            //    str = MessageFormat.Format(str, args);
+            //}
+
+            return str;
+        }
+
+        public static string GetLocalizedMessage(string key, params object[] args)
+        {
+            return GetLocalizedMessage(key, CultureInfo.InvariantCulture, args);
+        }
+
+        /**
+         * Initialize a given class with the message bundle Keys Should be called from
+         * a class that extends NLS in a static block at class load time.
+         * 
+         * @param bundleName
+         *          Property file with that contains the message bundle
+         * @param clazz
+         *          where constants will reside
+         */
+        protected static void InitializeMessages(string bundleName, Type clazz)
+        {
+            try
+            {
+                Load(clazz);
+                if (!bundles.ContainsKey(bundleName))
+                    bundles[bundleName] = clazz;
+            }
+            catch (Exception e)
+            {
+                // ignore all errors and exceptions
+                // because this function is supposed to be called at class load time.
+            }
+        }
+
+        private static object GetResourceBundleObject(string messageKey, CultureInfo locale)
+        {
+            // Set the UI culture to the passed in locale.
+            using (var culture = new CultureContext(locale, locale))
+            {
+
+                // slow resource checking
+                // need to loop thru all registered resource bundles
+                for (IEnumerator<string> it = bundles.Keys.GetEnumerator(); it.MoveNext();)
+                {
+                    Type clazz = bundles[it.Current];
+                    ResourceManager resourceBundle = new ResourceManager(clazz);
+                    if (resourceBundle != null)
+                    {
+                        try
+                        {
+                            object obj = resourceBundle.GetObject(messageKey);
+                            if (obj != null)
+                                return obj;
+                        }
+                        catch (MissingManifestResourceException e)
+                        {
+                            // just continue it might be on the next resource bundle
+                        }
+                    }
+
+
+                    //ResourceBundle resourceBundle = ResourceBundle.getBundle(clazz.Name,
+                    //    locale);
+                    //if (resourceBundle != null)
+                    //{
+                    //    try
+                    //    {
+                    //        object obj = resourceBundle.getObject(messageKey);
+                    //        if (obj != null)
+                    //            return obj;
+                    //    }
+                    //    catch (MissingResourceException e)
+                    //    {
+                    //        // just continue it might be on the next resource bundle
+                    //    }
+                    //}
+                }
+                // if resource is not found
+                return null;
+            }
+        }
+
+        private static void Load(Type clazz)
+        {
+            FieldInfo[] fieldArray = clazz.GetFields();
+
+            //bool isFieldAccessible = (clazz.getModifiers() & Modifier.PUBLIC) != 0;
+
+            // build a map of field names to Field objects
+            int len = fieldArray.Length;
+            IDictionary<string, FieldInfo> fields = new Dictionary<string, FieldInfo>(len * 2);
+            for (int i = 0; i < len; i++)
+            {
+                fields[fieldArray[i].Name] = fieldArray[i];
+                loadfieldValue(fieldArray[i], /*isFieldAccessible,*/ clazz);
+            }
+        }
+
+        private static void loadfieldValue(FieldInfo field, Type clazz)
+        {
+            field.SetValue(null, field.Name);
+            ValidateMessage(field.Name, clazz);
+
+
+            //int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
+            //int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
+            //if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
+            //    return;
+
+            //// Set a value for this empty field.
+            //if (!isFieldAccessible)
+            //    MakeAccessible(field);
+            //try
+            //{
+            //    field.SetValue(null, field.Name);
+            //    ValidateMessage(field.Name, clazz);
+            //}
+            //catch (ArgumentException e)
+            //{
+            //    // should not happen
+            //}
+            ////catch (IllegalAccessException e)
+            ////{
+            ////    // should not happen
+            ////}
+        }
+
+        //private static void loadfieldValue(FieldInfo field, bool isFieldAccessible,
+        //    Type clazz)
+        //{
+        //    int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
+        //    int MOD_MASK = MOD_EXPECTED | Modifier.FINAL;
+        //    if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED)
+        //        return;
+
+        //    // Set a value for this empty field.
+        //    if (!isFieldAccessible)
+        //        MakeAccessible(field);
+        //    try
+        //    {
+        //        field.SetValue(null, field.Name);
+        //        ValidateMessage(field.Name, clazz);
+        //    }
+        //    catch (ArgumentException e)
+        //    {
+        //        // should not happen
+        //    }
+        //    //catch (IllegalAccessException e)
+        //    //{
+        //    //    // should not happen
+        //    //}
+        //}
+
+        /**
+         * @param key
+         *          - Message Key
+         */
+        private static void ValidateMessage(string key, Type clazz)
+        {
+            // Test if the message is present in the resource bundle
+            try
+            {
+                ResourceManager resourceBundle = new ResourceManager(clazz);
+                if (resourceBundle != null)
+                {
+                    object obj = resourceBundle.GetObject(key);
+                    //if (obj == null)
+                    //  System.err.println("WARN: Message with key:" + key + " and locale: "
+                    //      + Locale.getDefault() + " not found.");
+                }
+            }
+            catch (MissingManifestResourceException e)
+            {
+                //System.err.println("WARN: Message with key:" + key + " and locale: "
+                //    + Locale.getDefault() + " not found.");
+            }
+            catch (Exception e)
+            {
+                // ignore all other errors and exceptions
+                // since this code is just a test to see if the message is present on the
+                // system
+            }
+
+            //// Test if the message is present in the resource bundle
+            //try
+            //{
+            //    ResourceBundle resourceBundle = ResourceBundle.getBundle(clazz.Name,
+            //        CultureInfo.InvariantCulture);
+            //    if (resourceBundle != null)
+            //    {
+            //        Object obj = resourceBundle.getObject(key);
+            //        //if (obj == null)
+            //        //  System.err.println("WARN: Message with key:" + key + " and locale: "
+            //        //      + Locale.getDefault() + " not found.");
+            //    }
+            //}
+            //catch (MissingResourceException e)
+            //{
+            //    //System.err.println("WARN: Message with key:" + key + " and locale: "
+            //    //    + Locale.getDefault() + " not found.");
+            //}
+            //catch (Exception e)
+            //{
+            //    // ignore all other errors and exceptions
+            //    // since this code is just a test to see if the message is present on the
+            //    // system
+            //}
+        }
+
+  //      /*
+  //       * Make a class field accessible
+  //       */
+  //      private static void MakeAccessible(FieldInfo field)
+  //      {
+  //          if (System.getSecurityManager() == null)
+  //          {
+  //              field.setAccessible(true);
+  //          }
+  //          else
+  //          {
+  //              AccessController.doPrivileged(new PrivilegedAction<Void>() {
+  //      @Override
+  //      public Void run()
+  //      {
+  //          field.setAccessible(true);
+  //          return null;
+  //      }
+  //  });
+  //  }
+  //}
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
new file mode 100644
index 0000000..b5a8612
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Messages
+{
+    /// <summary>
+    /// Interface that exceptions should implement to support lazy loading of messages.
+    /// 
+    /// For Native Language Support (NLS), system of software internationalization.
+    /// 
+    /// This Interface should be implemented by all exceptions that require
+    /// translation
+    /// </summary>
+    public interface INLSException
+    {
+        /// <summary>
+        /// an instance of a class that implements the Message interface
+        /// </summary>
+        IMessage MessageObject { get; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Precedence/PrecedenceQueryParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Precedence/PrecedenceQueryParser.cs b/src/Lucene.Net.QueryParser/Flexible/Precedence/PrecedenceQueryParser.cs
new file mode 100644
index 0000000..e1583cb
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Precedence/PrecedenceQueryParser.cs
@@ -0,0 +1,41 @@
+using Lucene.Net.Analysis;
+using Lucene.Net.QueryParsers.Flexible.Precedence.Processors;
+using Lucene.Net.QueryParsers.Flexible.Standard;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Precedence
+{
+    /// <summary>
+    /// This query parser works exactly as the standard query parser ( {@link StandardQueryParser} ), 
+    /// except that it respect the boolean precedence, so &lt;a AND b OR c AND d&gt; is parsed to &lt;(+a +b) (+c +d)&gt;
+    /// instead of &lt;+a +b +c +d&gt;.
+    /// <para>
+    /// EXPERT: This class extends {@link StandardQueryParser}, but uses {@link PrecedenceQueryNodeProcessorPipeline}
+    /// instead of {@link StandardQueryNodeProcessorPipeline} to process the query tree.
+    /// </para>
+    /// </summary>
+    /// <seealso cref="StandardQueryParser"/>
+    public class PrecedenceQueryParser : StandardQueryParser
+    {
+        /**
+   * @see StandardQueryParser#StandardQueryParser()
+   */
+        public PrecedenceQueryParser()
+        {
+            SetQueryNodeProcessor(new PrecedenceQueryNodeProcessorPipeline(GetQueryConfigHandler()));
+        }
+
+        /**
+         * @see StandardQueryParser#StandardQueryParser(Analyzer)
+         */
+        public PrecedenceQueryParser(Analyzer analyer)
+            : base(analyer)
+        {
+            SetQueryNodeProcessor(new PrecedenceQueryNodeProcessorPipeline(GetQueryConfigHandler()));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
new file mode 100644
index 0000000..45ed21f
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/BooleanModifiersQueryNodeProcessor.cs
@@ -0,0 +1,127 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Core.Processors;
+using Lucene.Net.QueryParsers.Flexible.Standard.Config;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Precedence.Processors
+{
+    /// <summary>
+    /// This processor is used to apply the correct {@link ModifierQueryNode} to {@link BooleanQueryNode}s children.
+    /// <para>
+    /// It walks through the query node tree looking for {@link BooleanQueryNode}s. If an {@link AndQueryNode} is found,
+    /// every child, which is not a {@link ModifierQueryNode} or the {@link ModifierQueryNode} 
+    /// is {@link Modifier#MOD_NONE}, becomes a {@link Modifier#MOD_REQ}. For any other
+    /// {@link BooleanQueryNode} which is not an {@link OrQueryNode}, it checks the default operator is {@link Operator#AND},
+    /// if it is, the same operation when an {@link AndQueryNode} is found is applied to it.
+    /// </para>
+    /// </summary>
+    /// <seealso cref="ConfigurationKeys#DEFAULT_OPERATOR"/>
+    /// <seealso cref="PrecedenceQueryParser#setDefaultOperator"/>
+    public class BooleanModifiersQueryNodeProcessor : QueryNodeProcessorImpl
+    {
+        private List<IQueryNode> childrenBuffer = new List<IQueryNode>();
+
+        private bool usingAnd = false;
+
+        public BooleanModifiersQueryNodeProcessor()
+        {
+            // empty constructor
+        }
+
+
+        public override IQueryNode Process(IQueryNode queryTree)
+        {
+            Operator? op = GetQueryConfigHandler().Get(ConfigurationKeys.DEFAULT_OPERATOR);
+
+            if (op == null)
+            {
+                throw new ArgumentException(
+                    "StandardQueryConfigHandler.ConfigurationKeys.DEFAULT_OPERATOR should be set on the QueryConfigHandler");
+            }
+
+            this.usingAnd = Operator.AND == op;
+
+            return base.Process(queryTree);
+
+        }
+
+
+        protected override IQueryNode PostProcessNode(IQueryNode node)
+        {
+
+            if (node is AndQueryNode)
+            {
+                this.childrenBuffer.Clear();
+                IList<IQueryNode> children = node.GetChildren();
+
+                foreach (IQueryNode child in children)
+                {
+                    this.childrenBuffer.Add(ApplyModifier(child, Modifier.MOD_REQ));
+                }
+
+                node.Set(this.childrenBuffer);
+
+            }
+            else if (this.usingAnd && node is BooleanQueryNode
+              && !(node is OrQueryNode))
+            {
+
+                this.childrenBuffer.Clear();
+                IList<IQueryNode> children = node.GetChildren();
+
+                foreach (IQueryNode child in children)
+                {
+                    this.childrenBuffer.Add(ApplyModifier(child, Modifier.MOD_REQ));
+                }
+
+                node.Set(this.childrenBuffer);
+
+            }
+
+            return node;
+
+        }
+
+        private IQueryNode ApplyModifier(IQueryNode node, Modifier mod)
+        {
+
+            // check if modifier is not already defined and is default
+            if (!(node is ModifierQueryNode))
+            {
+                return new ModifierQueryNode(node, mod);
+
+            }
+            else
+            {
+                ModifierQueryNode modNode = (ModifierQueryNode)node;
+
+                if (modNode.GetModifier() == Modifier.MOD_NONE)
+                {
+                    return new ModifierQueryNode(modNode.GetChild(), mod);
+                }
+
+            }
+
+            return node;
+
+        }
+
+
+        protected override IQueryNode PreProcessNode(IQueryNode node)
+        {
+            return node;
+        }
+
+
+        protected override IList<IQueryNode> SetChildrenOrder(IList<IQueryNode> children)
+        {
+
+            return children;
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/PrecedenceQueryNodeProcessorPipeline.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/PrecedenceQueryNodeProcessorPipeline.cs b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/PrecedenceQueryNodeProcessorPipeline.cs
new file mode 100644
index 0000000..c8bc616
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Precedence/Processors/PrecedenceQueryNodeProcessorPipeline.cs
@@ -0,0 +1,46 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Config;
+using Lucene.Net.QueryParsers.Flexible.Standard.Processors;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Precedence.Processors
+{
+    /// <summary>
+    /// This processor pipeline extends {@link StandardQueryNodeProcessorPipeline} and enables
+    /// boolean precedence on it.
+    /// <para>
+    /// EXPERT: the precedence is enabled by removing {@link GroupQueryNodeProcessor} from the
+    /// {@link StandardQueryNodeProcessorPipeline} and appending {@link BooleanModifiersQueryNodeProcessor}
+    /// to the pipeline.
+    /// </para>
+    /// </summary>
+    /// <seealso cref="PrecedenceQueryParser"/>
+    /// <seealso cref="StandardQueryNodeProcessorPipeline"/>
+    public class PrecedenceQueryNodeProcessorPipeline : StandardQueryNodeProcessorPipeline
+    {
+        /**
+   * @see StandardQueryNodeProcessorPipeline#StandardQueryNodeProcessorPipeline(QueryConfigHandler)
+   */
+        public PrecedenceQueryNodeProcessorPipeline(QueryConfigHandler queryConfig)
+            : base(queryConfig)
+        {
+            for (int i = 0; i < Count; i++)
+            {
+
+                if (this[i].GetType().Equals(typeof(BooleanQuery2ModifierNodeProcessor)))
+                {
+                    RemoveAt(i--);
+                }
+
+            }
+
+
+            Add(new BooleanModifiersQueryNodeProcessor());
+
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/AnyQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/AnyQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/AnyQueryNodeBuilder.cs
new file mode 100644
index 0000000..a31e56a
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/AnyQueryNodeBuilder.cs
@@ -0,0 +1,80 @@
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a BooleanQuery of SHOULD clauses, possibly with
+    /// some minimum number to match.
+    /// </summary>
+    public class AnyQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public AnyQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            AnyQueryNode andNode = (AnyQueryNode)queryNode;
+
+            BooleanQuery bQuery = new BooleanQuery();
+            IList<IQueryNode> children = andNode.GetChildren();
+
+            if (children != null)
+            {
+
+                foreach (IQueryNode child in children)
+                {
+                    object obj = child.GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+                    if (obj != null)
+                    {
+                        Query query = (Query)obj;
+
+                        try
+                        {
+                            bQuery.Add(query, BooleanClause.Occur.SHOULD);
+                        }
+                        catch (BooleanQuery.TooManyClauses ex)
+                        {
+
+                            throw new QueryNodeException(new MessageImpl(
+                               /*
+                                * IQQQ.Q0028E_TOO_MANY_BOOLEAN_CLAUSES,
+                                * BooleanQuery.getMaxClauseCount()
+                                */QueryParserMessages.EMPTY_MESSAGE), ex);
+
+                        }
+
+                    }
+
+                }
+
+            }
+
+            bQuery.MinimumNumberShouldMatch = andNode.GetMinimumMatchingElements();
+
+            return bQuery;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BooleanQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BooleanQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BooleanQueryNodeBuilder.cs
new file mode 100644
index 0000000..0486e89
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BooleanQueryNodeBuilder.cs
@@ -0,0 +1,112 @@
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.QueryParsers.Flexible.Standard.Parser;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link BooleanQuery} object from a {@link BooleanQueryNode} object.
+    /// Every children in the {@link BooleanQueryNode} object must be already tagged
+    /// using {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} with a {@link Query}
+    /// object.
+    /// <para>
+    /// It takes in consideration if the children is a {@link ModifierQueryNode} to
+    /// define the {@link BooleanClause}.
+    /// </para>
+    /// </summary>
+    public class BooleanQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public BooleanQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            BooleanQueryNode booleanNode = (BooleanQueryNode)queryNode;
+
+            BooleanQuery bQuery = new BooleanQuery();
+            IList<IQueryNode> children = booleanNode.GetChildren();
+
+            if (children != null)
+            {
+
+                foreach (IQueryNode child in children)
+                {
+                    object obj = child.GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+                    if (obj != null)
+                    {
+                        Query query = (Query)obj;
+
+                        try
+                        {
+                            bQuery.Add(query, GetModifierValue(child));
+
+                        }
+                        catch (BooleanQuery.TooManyClauses ex)
+                        {
+
+                            throw new QueryNodeException(new MessageImpl(
+                                QueryParserMessages.TOO_MANY_BOOLEAN_CLAUSES, BooleanQuery
+                                    .MaxClauseCount, queryNode
+                                    .ToQueryString(new EscapeQuerySyntaxImpl())), ex);
+
+                        }
+
+                    }
+
+                }
+
+            }
+
+            return bQuery;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+
+        private static BooleanClause.Occur GetModifierValue(IQueryNode node)
+        {
+
+            if (node is ModifierQueryNode)
+            {
+                ModifierQueryNode mNode = ((ModifierQueryNode)node);
+                switch (mNode.GetModifier())
+                {
+
+                    case Modifier.MOD_REQ:
+                        return BooleanClause.Occur.MUST;
+
+                    case Modifier.MOD_NOT:
+                        return BooleanClause.Occur.MUST_NOT;
+
+                    case Modifier.MOD_NONE:
+                        return BooleanClause.Occur.SHOULD;
+
+                }
+
+            }
+
+            return BooleanClause.Occur.SHOULD;
+
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BoostQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BoostQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BoostQueryNodeBuilder.cs
new file mode 100644
index 0000000..eff296e
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/BoostQueryNodeBuilder.cs
@@ -0,0 +1,51 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// This builder basically reads the {@link Query} object set on the
+    /// {@link BoostQueryNode} child using
+    /// {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} and applies the boost value
+    /// defined in the {@link BoostQueryNode}.
+    /// </summary>
+    public class BoostQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public BoostQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            BoostQueryNode boostNode = (BoostQueryNode)queryNode;
+            IQueryNode child = boostNode.GetChild();
+
+            if (child == null)
+            {
+                return null;
+            }
+
+            Query query = (Query)child
+                .GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+            query.Boost = boostNode.GetValue();
+
+            return query;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/DummyQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/DummyQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/DummyQueryNodeBuilder.cs
new file mode 100644
index 0000000..c2a5dfe
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/DummyQueryNodeBuilder.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// This builder does nothing. Commonly used for {@link QueryNode} objects that
+    /// are built by its parent's builder.
+    /// </summary>
+    /// <seealso cref="IStandardQueryBuilder"/>
+    /// <seealso cref="QueryTreeBuilder"/>
+    public class DummyQueryNodeBuilder : IStandardQueryBuilder
+    {
+        /// <summary>
+        /// Constructs a {@link DummyQueryNodeBuilder} object.
+        /// </summary>
+        public DummyQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+        /// <summary>
+        /// Always return <c>null</c>.
+        /// </summary>
+        /// <param name="queryNode"></param>
+        /// <returns><c>null</c></returns>
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            return null;
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FieldQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FieldQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FieldQueryNodeBuilder.cs
new file mode 100644
index 0000000..f3a112a
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FieldQueryNodeBuilder.cs
@@ -0,0 +1,40 @@
+using Lucene.Net.Index;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link TermQuery} object from a {@link FieldQueryNode} object.
+    /// </summary>
+    public class FieldQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public FieldQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            FieldQueryNode fieldNode = (FieldQueryNode)queryNode;
+
+            return new TermQuery(new Term(fieldNode.GetFieldAsString(), fieldNode
+                .GetTextAsString()));
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FuzzyQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FuzzyQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FuzzyQueryNodeBuilder.cs
new file mode 100644
index 0000000..549b2a2
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/FuzzyQueryNodeBuilder.cs
@@ -0,0 +1,48 @@
+using Lucene.Net.Index;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link FuzzyQuery} object from a {@link FuzzyQueryNode} object.
+    /// </summary>
+    public class FuzzyQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public FuzzyQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            FuzzyQueryNode fuzzyNode = (FuzzyQueryNode)queryNode;
+            string text = fuzzyNode.GetTextAsString();
+
+
+            int numEdits = FuzzyQuery.FloatToEdits(fuzzyNode.GetSimilarity(),
+                text.CodePointCount(0, text.Length));
+
+            return new FuzzyQuery(new Term(fuzzyNode.GetFieldAsString(), fuzzyNode
+                .GetTextAsString()), numEdits, fuzzyNode
+                .GetPrefixLength());
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/GroupQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/GroupQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/GroupQueryNodeBuilder.cs
new file mode 100644
index 0000000..faafdfb
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/GroupQueryNodeBuilder.cs
@@ -0,0 +1,42 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds no object, it only returns the {@link Query} object set on the
+    /// {@link GroupQueryNode} object using a
+    /// {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} tag.
+    /// </summary>
+    public class GroupQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public GroupQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            GroupQueryNode groupNode = (GroupQueryNode)queryNode;
+
+            return (Query)(groupNode).GetChild().GetTag(
+                QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchAllDocsQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchAllDocsQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchAllDocsQueryNodeBuilder.cs
new file mode 100644
index 0000000..cf930d3
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchAllDocsQueryNodeBuilder.cs
@@ -0,0 +1,52 @@
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.QueryParsers.Flexible.Standard.Parser;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link MatchAllDocsQuery} object from a
+    /// {@link MatchAllDocsQueryNode} object.
+    /// </summary>
+    public class MatchAllDocsQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public MatchAllDocsQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+
+            // validates node
+            if (!(queryNode is MatchAllDocsQueryNode))
+            {
+                throw new QueryNodeException(new MessageImpl(
+                    QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, queryNode
+                        .ToQueryString(new EscapeQuerySyntaxImpl()), queryNode.GetType()
+                        .Name));
+            }
+
+            return new MatchAllDocsQuery();
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchNoDocsQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchNoDocsQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchNoDocsQueryNodeBuilder.cs
new file mode 100644
index 0000000..7ad2c7b
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MatchNoDocsQueryNodeBuilder.cs
@@ -0,0 +1,53 @@
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.QueryParsers.Flexible.Standard.Parser;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds an empty {@link BooleanQuery} object from a
+    /// {@link MatchNoDocsQueryNode} object.
+    /// </summary>
+    public class MatchNoDocsQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public MatchNoDocsQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+
+            // validates node
+            if (!(queryNode is MatchNoDocsQueryNode))
+            {
+                throw new QueryNodeException(new MessageImpl(
+                    QueryParserMessages.LUCENE_QUERY_CONVERSION_ERROR, queryNode
+                        .ToQueryString(new EscapeQuerySyntaxImpl()), queryNode.GetType()
+                        .Name));
+            }
+
+            return new BooleanQuery();
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/ModifierQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/ModifierQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/ModifierQueryNodeBuilder.cs
new file mode 100644
index 0000000..0911a0c
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/ModifierQueryNodeBuilder.cs
@@ -0,0 +1,42 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds no object, it only returns the {@link Query} object set on the
+    /// {@link ModifierQueryNode} object using a
+    /// {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} tag.
+    /// </summary>
+    public class ModifierQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public ModifierQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            ModifierQueryNode modifierNode = (ModifierQueryNode)queryNode;
+
+            return (Query)(modifierNode).GetChild().GetTag(
+                QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MultiPhraseQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MultiPhraseQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MultiPhraseQueryNodeBuilder.cs
new file mode 100644
index 0000000..7a22da8
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/MultiPhraseQueryNodeBuilder.cs
@@ -0,0 +1,83 @@
+using Lucene.Net.Index;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Nodes;
+using Lucene.Net.Search;
+using Lucene.Net.Support;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link MultiPhraseQuery} object from a {@link MultiPhraseQueryNode}
+    /// object.
+    /// </summary>
+    public class MultiPhraseQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public MultiPhraseQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            MultiPhraseQueryNode phraseNode = (MultiPhraseQueryNode)queryNode;
+
+            MultiPhraseQuery phraseQuery = new MultiPhraseQuery();
+
+            IList<IQueryNode> children = phraseNode.GetChildren();
+
+            if (children != null)
+            {
+                //TreeDictionary<int?, List<Term>> positionTermMap = new TreeDictionary<int?, List<Term>>();
+                IDictionary<int?, List<Term>> positionTermMap = new SortedDictionary<int?, List<Term>>();
+
+                foreach (IQueryNode child in children)
+                {
+                    FieldQueryNode termNode = (FieldQueryNode)child;
+                    TermQuery termQuery = (TermQuery)termNode
+                        .GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+                    //List<Term> termList = positionTermMap[termNode.GetPositionIncrement()];
+                    //if (termList == null)
+                    List<Term> termList;
+                    if (!positionTermMap.TryGetValue(termNode.GetPositionIncrement(), out termList) || termList == null)
+                    {
+                        termList = new List<Term>();
+                        positionTermMap[termNode.GetPositionIncrement()] = termList;
+
+                    }
+
+                    termList.Add(termQuery.Term);
+
+                }
+
+                foreach (int positionIncrement in positionTermMap.Keys)
+                {
+                    List<Term> termList = positionTermMap[positionIncrement];
+
+                    phraseQuery.Add(termList.ToArray(/*new Term[termList.size()]*/),
+                                positionIncrement);
+
+                }
+
+            }
+
+            return phraseQuery;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/NumericRangeQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/NumericRangeQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/NumericRangeQueryNodeBuilder.cs
new file mode 100644
index 0000000..ce39a54
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/NumericRangeQueryNodeBuilder.cs
@@ -0,0 +1,91 @@
+using Lucene.Net.Documents;
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Core.Util;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.QueryParsers.Flexible.Standard.Config;
+using Lucene.Net.QueryParsers.Flexible.Standard.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds {@link NumericRangeQuery}s out of {@link NumericRangeQueryNode}s.
+    /// </summary>
+    /// <seealso cref="NumericRangeQuery"/>
+    /// <seealso cref="NumericRangeQueryNode"/>
+    public class NumericRangeQueryNodeBuilder : IStandardQueryBuilder
+    {
+        /**
+   * Constructs a {@link NumericRangeQueryNodeBuilder} object.
+   */
+        public NumericRangeQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            NumericRangeQueryNode numericRangeNode = (NumericRangeQueryNode)queryNode;
+
+            NumericQueryNode lowerNumericNode = (NumericQueryNode)numericRangeNode.LowerBound;
+            NumericQueryNode upperNumericNode = (NumericQueryNode)numericRangeNode.UpperBound;
+
+            /*Number*/
+            object lowerNumber = lowerNumericNode.Value;
+            /*Number*/
+            object upperNumber = upperNumericNode.Value;
+
+            NumericConfig numericConfig = numericRangeNode.GetNumericConfig();
+            FieldType.NumericType numberType = numericConfig.GetType();
+            string field = StringUtils.ToString(numericRangeNode.Field);
+            bool minInclusive = numericRangeNode.IsLowerInclusive;
+            bool maxInclusive = numericRangeNode.IsUpperInclusive;
+            int precisionStep = numericConfig.GetPrecisionStep();
+
+            switch (numberType)
+            {
+
+                case FieldType.NumericType.LONG:
+                    return NumericRangeQuery.NewLongRange(field, precisionStep,
+                        (long?)lowerNumber, (long?)upperNumber, minInclusive, maxInclusive);
+
+                case FieldType.NumericType.INT:
+                    return NumericRangeQuery.NewIntRange(field, precisionStep,
+                        (int?)lowerNumber, (int?)upperNumber, minInclusive,
+                        maxInclusive);
+
+                case FieldType.NumericType.FLOAT:
+                    return NumericRangeQuery.NewFloatRange(field, precisionStep,
+                        (float?)lowerNumber, (float?)upperNumber, minInclusive,
+                        maxInclusive);
+
+                case FieldType.NumericType.DOUBLE:
+                    return NumericRangeQuery.NewDoubleRange(field, precisionStep,
+                        (double?)lowerNumber, (double?)upperNumber, minInclusive,
+                        maxInclusive);
+
+                default:
+                    throw new QueryNodeException(new MessageImpl(
+                      QueryParserMessages.UNSUPPORTED_NUMERIC_DATA_TYPE, numberType));
+
+            }
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PhraseQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PhraseQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PhraseQueryNodeBuilder.cs
new file mode 100644
index 0000000..d9129b4
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PhraseQueryNodeBuilder.cs
@@ -0,0 +1,59 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link PhraseQuery} object from a {@link TokenizedPhraseQueryNode}
+    /// object.
+    /// </summary>
+    public class PhraseQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public PhraseQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public Query Build(IQueryNode queryNode)
+        {
+            TokenizedPhraseQueryNode phraseNode = (TokenizedPhraseQueryNode)queryNode;
+
+            PhraseQuery phraseQuery = new PhraseQuery();
+
+            IList<IQueryNode> children = phraseNode.GetChildren();
+
+            if (children != null)
+            {
+
+                foreach (IQueryNode child in children)
+                {
+                    TermQuery termQuery = (TermQuery)child
+                        .GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+                    FieldQueryNode termNode = (FieldQueryNode)child;
+
+                    phraseQuery.Add(termQuery.Term, termNode.GetPositionIncrement());
+
+                }
+
+            }
+
+            return phraseQuery;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PrefixWildcardQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PrefixWildcardQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PrefixWildcardQueryNodeBuilder.cs
new file mode 100644
index 0000000..2646b86
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/PrefixWildcardQueryNodeBuilder.cs
@@ -0,0 +1,52 @@
+using Lucene.Net.Index;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Processors;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link PrefixQuery} object from a {@link PrefixWildcardQueryNode}
+    /// object.
+    /// </summary>
+    public class PrefixWildcardQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public PrefixWildcardQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public 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;
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/RegexpQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/RegexpQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/RegexpQueryNodeBuilder.cs
new file mode 100644
index 0000000..d3f0fa5
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/RegexpQueryNodeBuilder.cs
@@ -0,0 +1,51 @@
+using Lucene.Net.Index;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Processors;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// Builds a {@link RegexpQuery} object from a {@link RegexpQueryNode} object.
+    /// </summary>
+    public class RegexpQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public RegexpQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            RegexpQueryNode regexpNode = (RegexpQueryNode)queryNode;
+
+            RegexpQuery q = new RegexpQuery(new Term(regexpNode.FieldAsString,
+        regexpNode.TextToBytesRef()));
+
+            MultiTermQuery.RewriteMethod method = (MultiTermQuery.RewriteMethod)queryNode
+                .GetTag(MultiTermRewriteMethodProcessor.TAG_ID);
+            if (method != null)
+            {
+                q.SetRewriteMethod(method);
+            }
+
+            return q;
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/SlopQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/SlopQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/SlopQueryNodeBuilder.cs
new file mode 100644
index 0000000..e64bb82
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/SlopQueryNodeBuilder.cs
@@ -0,0 +1,55 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// This builder basically reads the {@link Query} object set on the
+    /// {@link SlopQueryNode} child using
+    /// {@link QueryTreeBuilder#QUERY_TREE_BUILDER_TAGID} and applies the slop value
+    /// defined in the {@link SlopQueryNode}.
+    /// </summary>
+    public class SlopQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public SlopQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            SlopQueryNode phraseSlopNode = (SlopQueryNode)queryNode;
+
+            Query query = (Query)phraseSlopNode.GetChild().GetTag(
+                QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+            if (query is PhraseQuery)
+            {
+                ((PhraseQuery)query).Slop = phraseSlopNode.GetValue();
+
+            }
+            else
+            {
+                ((MultiPhraseQuery)query).Slop = phraseSlopNode.GetValue();
+            }
+
+            return query;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardBooleanQueryNodeBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardBooleanQueryNodeBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardBooleanQueryNodeBuilder.cs
new file mode 100644
index 0000000..3fc51ba
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardBooleanQueryNodeBuilder.cs
@@ -0,0 +1,112 @@
+using Lucene.Net.QueryParsers.Flexible.Core;
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Messages;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Messages;
+using Lucene.Net.QueryParsers.Flexible.Standard.Nodes;
+using Lucene.Net.QueryParsers.Flexible.Standard.Parser;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// This builder does the same as the {@link BooleanQueryNodeBuilder}, but this
+    /// considers if the built {@link BooleanQuery} should have its coord disabled or
+    /// not.
+    /// </summary>
+    /// <seealso cref="BooleanQueryNodeBuilder"/>
+    /// <seealso cref="BooleanQuery"/>
+    /// <seealso cref="Similarity#coord(int, int)"/>
+    public class StandardBooleanQueryNodeBuilder : IStandardQueryBuilder
+    {
+        public StandardBooleanQueryNodeBuilder()
+        {
+            // empty constructor
+        }
+
+
+        public virtual Query Build(IQueryNode queryNode)
+        {
+            StandardBooleanQueryNode booleanNode = (StandardBooleanQueryNode)queryNode;
+
+            BooleanQuery bQuery = new BooleanQuery(booleanNode.IsDisableCoord);
+            IList<IQueryNode> children = booleanNode.GetChildren();
+
+            if (children != null)
+            {
+
+                foreach (IQueryNode child in children)
+                {
+                    object obj = child.GetTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
+
+                    if (obj != null)
+                    {
+                        Query query = (Query)obj;
+
+                        try
+                        {
+                            bQuery.Add(query, GetModifierValue(child));
+                        }
+                        catch (BooleanQuery.TooManyClauses ex)
+                        {
+
+                            throw new QueryNodeException(new MessageImpl(
+                                QueryParserMessages.TOO_MANY_BOOLEAN_CLAUSES, BooleanQuery
+                                    .MaxClauseCount, queryNode
+                                    .ToQueryString(new EscapeQuerySyntaxImpl())), ex);
+
+                        }
+
+                    }
+
+                }
+
+            }
+
+            return bQuery;
+
+        }
+
+        /// <summary>
+        /// LUCENENET specific overload for supporting IQueryBuilder
+        /// </summary>
+        object IQueryBuilder.Build(IQueryNode queryNode)
+        {
+            return Build(queryNode);
+        }
+
+        private static BooleanClause.Occur GetModifierValue(IQueryNode node)
+        {
+
+            if (node is ModifierQueryNode)
+            {
+                ModifierQueryNode mNode = ((ModifierQueryNode)node);
+                Modifier modifier = mNode.GetModifier();
+
+                if (Modifier.MOD_NONE.Equals(modifier))
+                {
+                    return BooleanClause.Occur.SHOULD;
+
+                }
+                else if (Modifier.MOD_NOT.Equals(modifier))
+                {
+                    return BooleanClause.Occur.MUST_NOT;
+
+                }
+                else
+                {
+                    return BooleanClause.Occur.MUST;
+                }
+            }
+
+            return BooleanClause.Occur.SHOULD;
+
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c83be6be/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardQueryBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardQueryBuilder.cs b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardQueryBuilder.cs
new file mode 100644
index 0000000..3554ab8
--- /dev/null
+++ b/src/Lucene.Net.QueryParser/Flexible/Standard/Builders/StandardQueryBuilder.cs
@@ -0,0 +1,22 @@
+using Lucene.Net.QueryParsers.Flexible.Core.Builders;
+using Lucene.Net.QueryParsers.Flexible.Core.Nodes;
+using Lucene.Net.Search;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.QueryParsers.Flexible.Standard.Builders
+{
+    /// <summary>
+    /// This interface should be implemented by every class that wants to build
+    /// {@link Query} objects from {@link QueryNode} objects. 
+    /// </summary>
+    /// <seealso cref="IQueryBuilder"/>
+    /// <seealso cref="QueryTreeBuilder"/>
+    public interface IStandardQueryBuilder : IQueryBuilder
+    {
+        new Query Build(IQueryNode queryNode);
+    }
+}


Mime
View raw message