Events Elasticsearch搜索具有多个日期类型的事件
我正在ElasticSearch中搜索事件。每个事件都可以设置一个特定的开始日期(以秒为单位),或者事件一直持续到手动取消为止。在我的搜索查询中,我正在使用今天的日期搜索(以及其他参数),并希望找到以下所有事件:Events Elasticsearch搜索具有多个日期类型的事件,events,elasticsearch,Events,elasticsearch,我正在ElasticSearch中搜索事件。每个事件都可以设置一个特定的开始日期(以秒为单位),或者事件一直持续到手动取消为止。在我的搜索查询中,我正在使用今天的日期搜索(以及其他参数),并希望找到以下所有事件: 从今天开始(日期>今天,日期类型=特定) 或正在进行(日期类型=正在进行) 我的查询如下所示,但不起作用: "query":{ "bool":{ "must":[ { "range":{
- 从今天开始(日期>今天,日期类型=特定)
- 或正在进行(日期类型=正在进行)
"query":{
"bool":{
"must":[
{
"range":{
"latitude":{
"gte":45.78560033657945,
"lte":46.54954406342055
}
}
},
{
"range":{
"longitude":{
"gte":13.75487411320551,
"lte":14.857968686794491
}
}
},
{
"multi_match":{
"query":"tes",
"type":"phrase_prefix",
"fields":[
"title^3",
"subtitle^2"
]
}
}
],
"should":[
{
"range":{
"validDateUnix":{
"gte":1487026800000
}
}
}
]
}
}
任何帮助都将不胜感激。为了捕获两个约束,您需要处理您的
应部分,现在您只捕获了前一个约束的一半。试试这个:
"query":{
"bool":{
"must":[
{
"range":{
"latitude":{
"gte":45.78560033657945,
"lte":46.54954406342055
}
}
},
{
"range":{
"longitude":{
"gte":13.75487411320551,
"lte":14.857968686794491
}
}
},
{
"multi_match":{
"query":"tes",
"type":"phrase_prefix",
"fields":[
"title^3",
"subtitle^2"
]
}
}
],
"minimum_should_match": 1,
"should":[
{
"bool": {
"filter": [
{
"term": {
"dateType": "specific"
}
},
{
"range":{
"validDateUnix":{
"gte":1487026800000
}
}
}
]
}
},
{
"term": {
"dateType": "on-going"
}
}
]
}
}
谢谢你的回答,但似乎不起作用。结果包含过去的事件。因此,范围筛选器以某种方式让它们通过。第一部分现在工作正常,我只能筛选新事件,但不包括正在进行的事件。您能否显示一个应与正在进行的约束匹配的示例文档?@Val这是应与正在进行的条件匹配的示例文档。
{
"id": "7812c801-0000-0000-0000-000000000000",
"title": "Know Your Student Protest Rights",
"subtitle": "Know what you can and can't do. Join our campus communities to help other students understand their rights. Peer to peer advocacy is critical to our approach.",
"whatIsImpact": "The ACLU makes sure that our basic Constitutional rights – to free speech, to privacy, to be innocent until proven guilty – don’t just exist on paper, but also practice. The ACLU enforces the vision that these freedoms be guaranteed to every person in this country. These are our American values.",
"whatIsNeeded": "Our goal is to connect with young Americans so they understand their civic rights.",
"whyIsNeeded": "The ACLU of Northern California is an enduring guardian of justice, fairness, equality, and freedom, working to protect and advance civil liberties for all Californians. This includes students!",
"url": "https://www.aclunc.org",
"address": "Ljubljana, Slovenia",
"dateType": "on-going",
"issues": [],
"latitude": "46.1671294",
"longitude": "14.3058337",
"organization": "68c9c701-0000-0000-98c9-c70100000000",
"organizationName": "Developer test",
"type": "Volunteer"
}