All Products
Document Center

Use the SDK multi-value data model to query the latest data

Last Updated: May 24, 2020

Sample code

  1. /*
  2. * Use the multiFieldQueryLast() API.
  3. * The query method is similar to that for the single-value model. The difference is that you must provide the field information when you create a LastPointSubQuery request.
  4. * You must provide the following information when you perform a query:
  5. * Metric: the metric to be queried, for example, wind.
  6. * Fields: the specific fields of the metric, such as speed, level, and temperature. The fields are the sub-category of the metric.
  7. */
  8. List<String> fields = new ArrayList<>();
  9. fields.add("speed");
  10. fields.add("level");
  11. fields.add("temperature");
  12. LastPointSubQuery lastPointSubQuery = LastPointSubQuery.builder("wind", fields, Collections.emptyMap()).build(); // No filtering conditions are specified based on the tags.
  13. LastPointQuery lastPointQuery = LastPointQuery.builder().sub(lastPointSubQuery).tupleFormat(true).msResolution(false).build();
  14. List<MultiFieldQueryLastResult> results = tsdb.multiFieldQueryLast(lastPointQuery);