首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elassandra中的日期范围搜索

Elassandra中的日期范围搜索
EN

Stack Overflow用户
提问于 2018-10-31 15:36:09
回答 1查看 100关注 0票数 0

我创建了如下所示的索引。

代码语言:javascript
复制
curl -XPUT -H 'Content-Type: application/json' 'http://x.x.x.x:9200/date_index' -d '{
  "settings" : { "keyspace" : "keyspace1"},
  "mappings" : {
    "table1" : {
      "discover":"sent_date",
      "properties" : {
        "sent_date" : { "type": "date", "format": "yyyy-MM-dd HH:mm:ssZZ" }
        }
    }
  }
}'

我需要搜索与日期范围有关的结果,例如"from“:"2039-05-07 11:22:34+0000"," to”:"2039-05-07 11:22:34+0000“,两者都包括在内。我就像这样,

代码语言:javascript
复制
curl -XGET -H 'Content-Type: application/json' 'http://x.x.x.x:9200/date_index/_search?pretty=true' -d '
{
  "query" : {
    "aggregations" : {

    "date_range" : {
      "sent_date" : {
        "from" : "2039-05-07 11:22:34+0000",
        "to" : "2039-05-07 11:22:34+0000"
        }
      }
    }

  }
}'

我得到的错误如下所示。

代码语言:javascript
复制
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "no [query] registered for [aggregations]",
        "line" : 4,
        "col" : 22
      }
    ],
    "type" : "parsing_exception",
    "reason" : "no [query] registered for [aggregations]",
    "line" : 4,
    "col" : 22
  },
  "status" : 400

请给我建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-31 22:51:05

该查询似乎格式错误。请参阅https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html的日期范围聚合文档,并注意这些差异:

  • 您是在不定义任何查询的情况下引入查询的--您需要查询吗?
  • 你应该使用aggs而不是聚合
  • 应该将聚合命名为
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53087093

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档