cancel
Showing results for 
Search instead for 
Did you mean: 

OData Query: How to skip every second entry?

Former Member
0 Kudos

I have a small webapp consuming an OData service (in particular the Message Management Service API of SAP Cloud Platform Internet of Things Service). I want to add a query option to my query to skip (e.g.) every second entry. Is that possible with OData options and how? Is there another solution? Filtering the data after downloading would be very unsatisfying. Maybe this may help: The queried data is sort by a timestamp but the duration between to data entries (difference in the timestamp) may vary. So a simple filter by divisibility of the timestamp is not possible.

Thanks in advance!

Accepted Solutions (0)

Answers (1)

Answers (1)

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

Interesting, why do you want to get only the odd entries?

If your entries had a sequence number starting at zero you could use $filter=seqno mod 2 eq 0 to get the "even" ones and $filter=seqno mod 2 eq 1 to get the "odd" ones.

Former Member
0 Kudos

It was just an example. The OData service provides measurements. The customer can decide the time interval of the queried data. To shorten the data in cases of long time intervals I was thinking about sorting out every second (or third, or fourth) entry. But I found no way to do this.

Unfortunately, there is no sequence number inside the entries.

RalfHandl
Product and Topic Expert
Product and Topic Expert
0 Kudos

For "condensing" or "compressing" time series of measurements there's the "M4" algorithm described in http://www.vldb.org/pvldb/vol7/p797-jugel.pdf and implemented e.g. in IoT "Thing" services, see https://help.sap.com/viewer/350cb3262cb8496b9f5e9e8b039b52db/1.54.0.0/en-US/6fbcc0b3a84d4888bdcc7aed....

This nifty algorithm returns the "most important" subset of a time series given the time interval you are interested in and the "number of pixels" you want to plot.

However, this is a rather special kind of query and not part of the OData standard, so I've no idea whether the Message Management Service API supports this.