elasticsearch-sql icon indicating copy to clipboard operation
elasticsearch-sql copied to clipboard

时间查询报错和返回不了时间

Open toudsf opened this issue 3 years ago • 1 comments

SELECT create_tiime,count(create_tiime) cnt12 from test_a/b where create_tiime<'1650157200000' and create_tiime>'1650070800000' group by date_histogram(field='create_tiime','time_zone'='+08:00','interval'='1d','format'='yyyy-MM-dd','alias'='create_tiime') 1、date_format(create_tiime, 'yyyy-MM-dd hh:mm:ss')>'2022-04-17 9:00:00' 报错org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper: class_cast_exception: Cannot apply [>] operation to types [java.lang.String] and [java.lang.String]. 2、create_tiime返回的值为空 3、不支持offset吗 @shi-yuan

toudsf avatar Apr 17 '22 15:04 toudsf

用的哪个版本,explain是可以的

{
  "from": 0,
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "bool": {
                  "must": [
                    {
                      "range": {
                        "create_tiime": {
                          "from": null,
                          "to": "1650157200000",
                          "include_lower": true,
                          "include_upper": false,
                          "boost": 1
                        }
                      }
                    },
                    {
                      "range": {
                        "create_tiime": {
                          "from": "1650070800000",
                          "to": null,
                          "include_lower": false,
                          "include_upper": true,
                          "boost": 1
                        }
                      }
                    }
                  ],
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              }
            ],
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "create_tiime",
      "COUNT"
    ],
    "excludes": []
  },
  "stored_fields": "create_tiime",
  "aggregations": {
    "create_tiime": {
      "date_histogram": {
        "field": "create_tiime",
        "format": "yyyy-MM-dd",
        "time_zone": "+08:00",
        "interval": "1d",
        "offset": 0,
        "order": {
          "_key": "asc"
        },
        "keyed": false,
        "min_doc_count": 0
      },
      "aggregations": {
        "cnt12": {
          "value_count": {
            "field": "create_tiime"
          }
        }
      }
    }
  }
}

shi-yuan avatar Jul 04 '22 14:07 shi-yuan