1

When using the REST API to get measurements I can pass the revert parameter to reverse the order of the measurements:

https://tenant.cumulocity.com/measurement/measurements?revert=true

However, as soon as I pass an extra device as a parameter,

https://tenant.cumulocity.com/measurement/measurements?revert=true&source=876123

the revert keyword seems to stop working. The first value shown is sometime a day before the actual most recent value. In fact, when specifying revert=false or omitting the parameter, the timestamp of the first value shown is actually chronologically AFTER the timestamp of the value shown first with revert=true.

  • First Item with no source specified and revert=true: "2015-12-20T18:15:00.000+01:00"
  • First Item with source specified and revert=true: "2015-12-19T01:25:00.000+01:00"
  • First Item with source specified and revert=false: "2015-12-19T12:50:00.000+01:00"

Is there any explanation for this or is the revert keyword not valid when specifying a source?

1 Answers1

2

For full understand:

  • when someone query our data base we get proper index and return result according to this index (performance reasons); indexes are selected according to query parameters,

  • the parameter 'revert' work on this index and in exact meaning is return result in revert order to index order

Why in your cases you get wrong results:

First Item with no source specified and revert=true ...

we get 'natural' index(order of adding document to database), and return elements in revert order to order of adding. Match between order or adding and order of time is accidental

First Item with source specified ...

in this case we get index 'bySource' this is b-tree on 'source' property and will be sorted only by 'source'; in this case data wasn't ordered by 'time'

If you want have result by specific 'source' and ordered by 'time', you must force application to ues bySourceAndTime index :) and how to do this, please simply use this URL:

https://tenant.cumulocity.com/measurement/measurements?dateTo=2015-12-22&dateFrom=1970-01-01&source=10307&revert=false

in this case application get index bySourceAndByTime and index have data ordered by source and time and when you add revert = true the result will be in revert order to time.

Best regards,
Arkadiusz

b00b0
  • 76
  • 5