Time range query on date field


(Vikas Mestry) #1

Hello,

Is there a way to filter a date field (epoch_mills) with time range without specifying the date e.g.

I have a field "cpuusagetime" with value as 1483283988368, i would like to get all the documents which are within the time range of 8:00 AM to 9:00 AM without specifying the date (MM-dd-yyyy)

Alternatively i have split the date field into separate fields viz hour, min but I am unable to apply a bool range filter on different fields e.g.

"_source": {
		"cpuusagetime": 1483283988368,
		"seconds": 48,
		"min": 49,
		"month": 1,
		"hour": 8,
		"cpu_percentage": 37,
		"year": 2017,
		"machine": "user1",
		"day": 1,
		"user": "machine1"
	},

"_source": {
		"cpuusagetime": 1483286028368,
		"seconds": 48,
		"min": 23,
		"month": 1,
		"hour": 9,
		"cpu_percentage": 67,
		"year": 2017,
		"machine": "user1",
		"day": 1,
		"user": "machine1"
	}

Below is the query i am attempting

"query": {
		"bool": {
			"must": [{
					"range": {
						"hour": {
							"gte": "8",
							"lte": "9"
						}
					}
				}, {
					"range": {
						"min": {
							"gte": "20",
							"lte": "40"
						}
					}
				}
			]
		}
	}

(Vikas Mestry) #2

any suggestions please


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.