public ExpFunction(Expression <Func <T, object> > objectPath, Action <FunctionScoreDecayFieldDescriptor> descriptorBuilder)
        {
            _ExpDescriptor = new Dictionary <string, FunctionScoreDecayFieldDescriptor>();

            var resolver   = new PropertyNameResolver();
            var fieldName  = resolver.Resolve(objectPath);
            var descriptor = new FunctionScoreDecayFieldDescriptor();

            descriptorBuilder(descriptor);
            _ExpDescriptor[fieldName] = descriptor;
        }
Exemple #2
0
        public AnalyzeResponse Analyze <T>(Expression <Func <T, object> > selector, string index, string text) where T : class
        {
            selector.ThrowIfNull("selector");
            var fieldName     = PropertyNameResolver.Resolve(selector);
            var analyzeParams = new AnalyzeParams()
            {
                Index = index, Field = fieldName
            };

            return(this._Analyze(analyzeParams, text));
        }
        /// <summary>
        /// <para>Allows to add one or more sort on specific fields. Each sort can be reversed as well.
        /// The sort is defined on a per field level, with special field name for _score to sort by score.
        /// </para>
        /// <para>
        /// Sort descending.
        /// </para>
        /// </summary>
        public SearchDescriptor <T> SortDescending(Expression <Func <T, object> > objectPath)
        {
            if (this._Sort == null)
            {
                this._Sort = new Dictionary <string, object>();
            }

            var resolver  = new PropertyNameResolver();
            var fieldName = resolver.Resolve(objectPath);

            var fieldAttributes = resolver.ResolvePropertyAttributes(objectPath);

            if ((fieldAttributes.Where(x => x.AddSortField == true)).Any())
            {
                fieldName += ".sort";
            }

            this._Sort.Add(fieldName, "desc");
            return(this);
        }