我需要在nest 1.7中添加一个带有数值
的rangerfilter但是该类用字符串
定义GreaterThannamespace 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
}
我该如何解决这个问题?
答案 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
}
}
}