HDFGroup / hsds

Cloud-native, service based access to HDF data
https://www.hdfgroup.org/solutions/hdf-kita/
Apache License 2.0
126 stars 52 forks source link

Point selections - how to write correct query? #215

Closed Apollo3zehn closed 1 year ago

Apollo3zehn commented 1 year ago

I am trying to read data from HSDS with a point selection query parameter. For example, I would like to query the points

[
    [2, 4],
    [1, 3],
    [9, 9]
]

How would I do that? My current approach looks like this but it fails:

http://hsdshdflab.hdfgroup.org/datasets/d-d38053ea-3418fe27-22d9-478e7b-913279/value?domain=/shared/tall.h5&select=[[2, 1, 9],[4, 3, 9]]

What works is a syntax like ...&select=[0:3,[3,4,7]], but with that I cannot freely choose the points to be selected.

Strangely, the syntax ...&select=[[1, 2, 3],[4, 5, 6]] returns HTTP Status 200 OK, but no json data:

grafik

Any hint would be appreciated. Thanks :-)

jhendersonHDF commented 1 year ago

Hi @Apollo3zehn, referring to https://github.com/HDFGroup/hdf-rest-api/blob/master/DatasetOps/GET_Value.rst, that format is specifically used for retrieving values from a dataset using a hyperslab selection. If you want to retrieve values using a point selection, you should make a POST request to the dataset with the request body containing the point selection desired. See https://github.com/HDFGroup/hdf-rest-api/blob/master/DatasetOps/POST_Value.md for a description of what the request should look like.

Apollo3zehn commented 1 year ago

Thank you! Unfortunately this does not seem to work (or I am using it wrong):

❯ curl -X POST 'http://hsdshdflab.hdfgroup.org/datasets/d-d38053ea-3418fe27-22d9-478e7b-913279/value?domain=/shared/tall.h5' \
    -H 'Content-Type: application/json' \
    -d '{ "points": [2, 4, 1, 3, 9, 9] }'
500 Internal Server Error

Server got itself in trouble
jhendersonHDF commented 1 year ago

Based on your first post, am I correct in assuming that your dataset has two dimensions? If so, I think your request body would instead look like:

{ "points": [[2, 4], [1, 3], [9, 9]] }
Apollo3zehn commented 1 year ago

Thank you, its working now!