Esempio n. 1
0
        protected override IQueryNode PostProcessNode(IQueryNode node)
        {
            if (node is IFieldableNode &&
                (node.Parent == null || !(node.Parent is IFieldableNode)))
            {
                IFieldableNode     fieldNode = (IFieldableNode)node;
                QueryConfigHandler config    = GetQueryConfigHandler();

                if (config != null)
                {
                    string      field       = fieldNode.Field;
                    FieldConfig fieldConfig = config.GetFieldConfig(StringUtils.ToString(field));

                    if (fieldConfig != null)
                    {
                        float?boost = fieldConfig.Get(ConfigurationKeys.BOOST);

                        if (boost != null)
                        {
                            return(new BoostQueryNode(node, boost.Value));
                        }
                    }
                }
            }

            return(node);
        }
Esempio n. 2
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);
        }
        protected override IQueryNode PreProcessNode(IQueryNode node)
        {
            if (node is IFieldableNode)
            {
                this.processChildren = false;
                IFieldableNode fieldNode = (IFieldableNode)node;

                if (fieldNode.Field == null)
                {
                    string[] fields = GetQueryConfigHandler().Get(ConfigurationKeys.MULTI_FIELDS);

                    if (fields == null)
                    {
                        throw new ArgumentException(
                                  "StandardQueryConfigHandler.ConfigurationKeys.MULTI_FIELDS should be set on the QueryConfigHandler");
                    }

                    if (fields != null && fields.Length > 0)
                    {
                        fieldNode.Field = fields[0];

                        if (fields.Length == 1)
                        {
                            return(fieldNode);
                        }
                        else
                        {
                            List <IQueryNode> children = new List <IQueryNode>();
                            children.Add(fieldNode);

                            for (int i = 1; i < fields.Length; i++)
                            {
                                fieldNode       = (IFieldableNode)fieldNode.CloneTree();
                                fieldNode.Field = fields[i];

                                children.Add(fieldNode);
                            }

                            return(new GroupQueryNode(new OrQueryNode(children)));
                        }
                    }
                }
            }

            return(node);
        }