1

I don't get the examples that have - + in the command. I'm probably missing something that is well-known and I'm just not aware/or know where to get the info but for example at https://redis.io/docs/stack/timeseries/quickstart/

They have command TS.RANGE sensor1 - + FILTER_BY_TS 1626435230501 1626443276598

but I don't get what the - + is. Does anyone know?

LeanMan
  • 474
  • 1
  • 4
  • 18

2 Answers2

1

The command format is: TS.RANGE key fromTimestamp toTimestamp

From the doc:

fromTimestamp

is start timestamp for the range query. Use - to express the minimum possible timestamp (0).

toTimestamp

is end timestamp for the range query. Use + to express the maximum possible timestamp.

So in your case, it means DO NOT filter data by timestamp.

for_stack
  • 21,012
  • 4
  • 35
  • 48
  • I see thanks. I just didn't know it was there. The quick start doesn't explain the `-`, `+`. I think they should at a minimum explain the symbols. – LeanMan Aug 21 '22 at 21:00
1

TS.RANGE, TS.REVRANGE, TS.MRANGE, and TS.MREVRANGE are range commands. You need to specify the range start and end timestamps.

Instead of specifying concrete values, you can you - and + respectively.

RedisTimeSeries replaces - with the timestamp of the earliest sample in the time series, and + with the timestamp of the latest sample in the time series.

Note that the query you composed

TS.RANGE sensor1 - + FILTER_BY_TS 1626435230501 1626443276598

would report samples only for two specific timestamps: 1626435230501 and 1626443276598, as FILTER_BY_TS is used for specifying a set of exact timestamps - not a range (to retrieve results, you must have samples with these exact timestamps, and these timestamps must fall within [fromTimestamp .. toTimestamp] which is [- .. +] in your case).

If you want to retrieve all samples between timestamp 1626435230501 and timestamp 1626443276598, you should instead use

TS.RANGE sensor1 1626435230501 1626443276598

And if you want to retrieve all samples in the time series, you can use

TS.RANGE sensor1 - +
Lior Kogan
  • 19,919
  • 6
  • 53
  • 85
  • Thanks! What about those that have another `+`? For example: `TS.RANGE sensor1 - + + AGGREGATION avg 3600000`? – LeanMan Aug 21 '22 at 21:08
  • 1
    In this case the second `+` is ignored and the command is equivalent to `TS.RANGE sensor1 - + AGGREGATION avg 3600000`. RedisTimeSeries silently ignores command-line arguments it can't parse (you'll get the same result for `TS.RANGE sensor1 - + foo bar AGGREGATION avg 3600000` ) – Lior Kogan Aug 22 '22 at 05:32
  • ok thanks, just new to this so it wasn't obvious to me. Appreciate it. – LeanMan Aug 22 '22 at 05:35