protected override IQueryNode PreProcessNode(IQueryNode node)
        {
            if (node is FuzzyQueryNode)
            {
                FuzzyQueryNode     fuzzyNode = (FuzzyQueryNode)node;
                QueryConfigHandler config    = GetQueryConfigHandler();

                FuzzyConfig fuzzyConfig = null;

                if (config != null && (fuzzyConfig = config.Get(ConfigurationKeys.FUZZY_CONFIG)) != null)
                {
                    fuzzyNode.PrefixLength = fuzzyConfig.PrefixLength;

                    if (fuzzyNode.Similarity < 0)
                    {
                        fuzzyNode.Similarity = fuzzyConfig.MinSimilarity;
                    }
                }
                else if (fuzzyNode.Similarity < 0)
                {
                    throw new ArgumentException("No FUZZY_CONFIG set in the config");
                }
            }

            return(node);
        }
Esempio n. 2
0
        protected override IQueryNode PreProcessNode(IQueryNode node)
        {
            if (node is FuzzyQueryNode fuzzyNode)
            {
                QueryConfigHandler config = GetQueryConfigHandler();

                FuzzyConfig fuzzyConfig; // LUCENENET: IDE0059: Remove unnecessary value assignment

                if (config != null && (fuzzyConfig = config.Get(ConfigurationKeys.FUZZY_CONFIG)) != null)
                {
                    fuzzyNode.PrefixLength = fuzzyConfig.PrefixLength;

                    if (fuzzyNode.Similarity < 0)
                    {
                        fuzzyNode.Similarity = fuzzyConfig.MinSimilarity;
                    }
                }
                else if (fuzzyNode.Similarity < 0)
                {
                    throw new ArgumentException("No FUZZY_CONFIG set in the config");
                }
            }

            return(node);
        }
Esempio n. 3
0
        protected override IQueryNode PreProcessNode(IQueryNode node)
        {
            if (node is IFieldableNode)
            {
                IFieldableNode fieldNode = (IFieldableNode)node;

                QueryConfigHandler queryConfig = GetQueryConfigHandler();

                if (queryConfig == null)
                {
                    throw new ArgumentException(
                              "A config handler is expected by the processor UniqueFieldQueryNodeProcessor!");
                }

                if (!queryConfig.Has(SpansQueryConfigHandler.UNIQUE_FIELD))
                {
                    throw new ArgumentException(
                              "UniqueFieldAttribute should be defined in the config handler!");
                }

                String uniqueField = queryConfig.Get(SpansQueryConfigHandler.UNIQUE_FIELD);
                fieldNode.Field = (uniqueField);
            }

            return(node);
        }
        public virtual void BuildFieldConfig(FieldConfig fieldConfig)
        {
            IDictionary <string, NumericConfig> numericConfigMap = config
                                                                   .Get(ConfigurationKeys.NUMERIC_CONFIG_MAP);

            if (numericConfigMap != null)
            {
                if (numericConfigMap.TryGetValue(fieldConfig.Field, out NumericConfig numericConfig) && numericConfig != null)
                {
                    fieldConfig.Set(ConfigurationKeys.NUMERIC_CONFIG, numericConfig);
                }
            }
        }
        public override IQueryNode Process(IQueryNode queryTree)
        {
            QueryConfigHandler queryConfig = GetQueryConfigHandler();

            if (queryConfig != null)
            {
                int?defaultPhraseSlop = queryConfig.Get(ConfigurationKeys.PHRASE_SLOP);

                if (defaultPhraseSlop != null)
                {
                    this.defaultPhraseSlop = defaultPhraseSlop.Value;

                    return(base.Process(queryTree));
                }
            }

            return(queryTree);
        }
Esempio n. 6
0
 /// <summary>
 /// Returns the fields used to expand the query when the field for a
 /// certain query is <c>null</c>
 /// </summary>
 /// <returns>the fields used to expand the query</returns>
 public virtual string[] GetMultiFields()
 {
     return(QueryConfigHandler.Get(ConfigurationKeys.MULTI_FIELDS));
 }