使用数值嵌套 1.7 的范围

use range with numeric value nest 1.7

我需要在 nest 1.7 中添加一个带有数值的 rangerfilter,

但是 class 使用字符串定义 GreaterThan

namespace Nest
{
    public class RangeFilter : PlainFilter, IRangeFilter, IFieldNameFilter, IFilter
    {
        public RangeFilter();

        public RangeExecution? Execution { get; set; }
        public PropertyPathMarker Field { get; set; }
        public string Format { get; set; }
        public string GreaterThan { get; set; }
        public string GreaterThanOrEqualTo { get; set; }
        public string LowerThan { get; set; }
        public string LowerThanOrEqualTo { get; set; }
        public string TimeZone { get; set; }

        protected internal override void WrapInContainer(IFilterContainer container);
    }
}

所以我的查询是

  {
                    "range": {
                      "NbAnnonce": {
                        "gt": "0"
                      }

而不是

   {
                "range": {
                  "NbAnnonce": {
                    "gt": 0.0
                  }

请问我该如何解决这个问题?

你可以试试这个

new NumericRangeQuery
{
  Name = "named_query",
  Boost = 1.1,
  Field = "description",
  GreaterThan = 1.0,
  GreaterThanOrEqualTo = 1.1,
  LessThan = 2.1,
  LessThanOrEqualTo = 2.0
}

Json输出

{
  "range": {
    "description": {
      "_name": "named_query",
      "boost": 1.1,
      "gt": 1.0,
      "gte": 1.1,
      "lt": 2.1,
      "lte": 2.0
    }
  }
}