Skip to Content
0

OData Query: How to skip every second entry?

Apr 26 at 01:53 PM

72

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ralf Handl
Apr 27 at 12:33 PM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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.

0

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/6fbcc0b3a84d4888bdcc7aedbe974535.html.

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.

0