Skip to content
Hylke van der Schaaf edited this page Sep 16, 2019 · 9 revisions

Welcome to the SensorThingsServer wiki!

Tips & Tricks

  • Improving performance when filtering on Thing/properties or Observation/parameters: Jsonb columns
  • By default, only primary and foreign keys have indices on them. If your database grows large and you notice a significant slowdown, you should check which queries you use most, and add indices for those queries. A very common one is probably for Datastreams(x)/observations?$orderby=phenomenonTime desc
    CREATE INDEX "OBS-DS_ID-PHTIME_SE"
      ON "OBSERVATIONS"
      USING btree
      ("DATASTREAM_ID", "PHENOMENON_TIME_START" DESC, "PHENOMENON_TIME_END" DESC);
    

Experimental Features

These features are not (yet) part of the SensorThings API.

  • Time comparison functions SensorThings API Issue #2 : Adds the functions before, after, starts, finishes, during, meets, overlaps as described here: https://github.com/hylkevds/SensorThingsAPI/blob/timeFunctions/15-078r6.html
  • Accessing arrays in json, or MultiDatastream results SensorThings API Issue #22: Arrays can be accessed using [index], both on the url and in filters. Examples:
    v1.0/Observations(1169708)/result[1]
    v1.0/Things(1962)/properties/intArrayItem[1]
    v1.0/Things(1962)/properties/intIntArrayItem[0][1]
    v1.0/Things(1962)/properties/objArrayItem[0]/stringItem
    v1.0/Things?$filter=properties/intArrayItem[1] gt 10
    v1.0/Things?$filter=substringof('cdefgh', properties/objArrayItem[2]/stringItem)
    v1.0/Observations?$filter=parameters/objArrayItem[1]/booleanItem
    v1.0/Observations?/filter=parameters/objArrayItem[1]/intArrayItem[0] gt 9