elasticsearch6.x time-range query invalid bug
1.es6.8.1 time range query, the original writing is as follows:
GET /oms_historyalarm.historyalarm_recent/historyalarm_recent/_search
{
"query":{
"range":{
"fault_start_time":{
"from":"2019-10-28 00:00:00",
"to":"2019-10-28 17:46:03",
"format": "yyyy-MM-dd hh:mm:ss"
}
}
}
}
query results are as follows:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
2. Looked up many baidu resources but could not find a solution, finally went back to check the field type of es index, found that fault_start_time field storage type is String, in this case, es will default to participle query again, of course, but no return.
solution: simply identify the time field that needs to be filtered as a keyword and then es will not participle it. As follows: h2>
GET /oms_historyalarm.historyalarm_recent/historyalarm_recent/_search
{
"query":{
"range":{
"fault_start_time.keyword":{
"from":"2019-10-28 00:00:00",
"to":"2019-10-28 17:46:03",
"format": "yyyy-MM-dd hh:mm:ss"
}
}
}
}
GET /oms_historyalarm.historyalarm_recent/historyalarm_recent/_search
{
"query":{
"range":{
"fault_start_time.keyword":{
"from":"2019-10-28 00:00:00",
"to":"2019-10-28 17:46:03",
"format": "yyyy-MM-dd hh:mm:ss"
}
}
}
}
result: of course successful
hope you can help, if you have any questions please leave a comment.
Read More:
- 1067 – Invalid default value for ‘sex‘1366 – Incorrect string value: ‘\xE6\x8A\x80\xE6\x9C\xAF…‘ f
- Windows blue screen code query (bug check code)
- Bug:Install Microsoft Visual C++ 2008 Redistributable (x86) Failed Installation aborted, Result=1603
- Unity bug solution — invalid AABB inaabb
- SQL query time group_ Was cut by group_ CONCAT()
- “Invalid month” in SQL query
- Bug resolution of 0xc0000005: access conflict occurred when reading location of 0x00000000.
- ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in range(128)
- RuntimeError: Expected hidden[0] size (x, x, x), got(x, x, x)
- MySQL:ERROR 1067 (42000): Invalid default value for ‘end_time’
- Bug001: error in gradle configuration environment variable: ERROR:JAVA_ Home is set to an invalid directory!
- Elasticsearch startup process error: org.elasticsearch.transport .BindTransportException: Failed to bind to [9300-9400
- [Solved] emulator: glteximage2d: got err pre 🙁 0x502 internal 0x1908 format 0x1908 type 0x1401
- The time of the time database displayed by the front end is inconsistent
- ERROR: invalid byte sequence for encoding “UTF8”: 0x00
- How to get the current time in java time string
- After IOS upgrade, the time control selected by the wheel will be invalid, uidatepicker
- MongoDB Error: Query failed with error code 2 and error message ‘Field ‘locale’ is invalid
- CLP: error: getaddrinfo enotfound http://x.x.x.x/
- Invalid Drive:H:\ (subst X: %TEMP%)