【发布时间】:2020-08-19 08:02:12
【问题描述】:
我正在尝试将以下 JSON 转换为 NEST,但它没有按预期工作。它确实将字段与网站匹配,但与范围不匹配,所以我得到了一些非常旧的结果。
当使用 Kibana 搜索时,我发送这个请求:
"query": {
"bool": {
"must": [],
"filter": [
{
"bool": {
"should": [
{
"match": {
"domain": "website.com"
}
}
],
"minimum_should_match": 1
}
},
{
"range": {
"@timestamp": {
"gte": "2020-08-03T12:37:07.821Z",
"lte": "2020-08-18T12:37:07.821Z",
"format": "strict_date_optional_time"
}
}
}
],
"should": [],
"must_not": []
}
},
并转换为 NEST:
SearchDescriptor<ApacheRequest> Query(SearchDescriptor<ApacheRequest> qc)
{
var query = qc.Query(q =>
q.Bool(b =>
b.Filter(f =>
f.Bool(fb =>
fb.Should(sh =>
sh.Match(ma => ma
.Field(x => x.Domain)
.Query("website.com")
)
)
),
f => f.Range(r => r.GreaterThanOrEquals(timestamp))
)
)
);
return query;
}
正如我所说,它匹配域,但不匹配范围。即使我已经测试过我的timestamp 是正确的,我也会在一个月前得到结果。
我做错了什么?
【问题讨论】:
-
@Val 给我一个
The name 'f' does not exist in the current context
标签: elasticsearch kibana nest