NASA-PDS / pds-api

PDS web APIs specifications and user's manual
http://nasa-pds.github.io/pds-api
Other
5 stars 3 forks source link

PDS API documents are unclear wrt quoting in queries #260

Closed msbentley closed 1 year ago

msbentley commented 1 year ago

Checked for duplicates

No - I haven't checked

šŸ› Describe the bug

When searching for data with the PDS API, it is unclear when and what kind of quotes are required in query strings.

The docs suggest this should work:

pds:Time_Coordinates.pds:start_date_timeĀ gtĀ 2001-05-10T00:00:00Z

but it doesn't seem to. Neither does

pds:Time_Coordinates.pds:start_date_timeĀ gtĀ '2001-05-10T00:00:00Z'

however this works OK:

pds:Time_Coordinates.pds:start_date_timeĀ gtĀ "2001-05-10T00:00:00Z"

šŸ•µļø Expected behavior

I expected that the documents or a return error message explain what kind of quoting is needed.

šŸ“œ To Reproduce

Execute the query as above.

āš™ļø Engineering Details

Acceptance Criteria

jordanpadams commented 1 year ago

@tloubrieu-jpl @alexdunnjpl can you take a look here as well!

alexdunnjpl commented 1 year ago

@msbentley when referencing use of the API, are you using the swagger docs, the API documentation, both, or neither?

The API documents syntax correctly details the format for query strings

{literal value} is either a string between " (double quotes) or a numerical value (float or integer)

but that does no good if it's not easy to find, so feedback on that would be useful.

Likewise, the API self-documentation (redirects from https://pds.nasa.gov/api/search/) states

syntax: q="vid eq 13.0"

behavior: query uses eq,ne,gt,ge,lt,le,(,),not,and,or operators. Properties are named as in 'properties' attributes, literals are strings between quotes, like "animal", or numbers. Detailed query specification is available at https://bit.ly/3h3D54T

note: ignored when keyword is present

(though this should explicitly specify double-quotes - @jordanpadams, is this documentation generated from SwaggerHub or elsewhere? Also the linked detailed query specification doesn't actually include a "Query sting syntax" section, despite referring to it, which we should fix)

Not trying to RTFM you @msbentley , just understand exactly where the existing doco is failing.

msbentley commented 1 year ago

Hi @alexdunnjpl I was using the API docs (first link in your reply), and in particular the examples shown in the query syntax section:

image

It's true that the if I had read the full doc I would have found the double quotes mention, but I was lazy and trying to work from examples ;-)

alexdunnjpl commented 1 year ago

@msbentley kind of a reasonable assumption that if you plug in the examples, they'll work šŸ˜…

I'll work through the docs and fix any discrepancies like that.

msbentley commented 1 year ago

Thanks @alexdunnjpl - that same table also contains examples that don't work because they use "fake" attributes to query on, so it would also be good to update those, e.g.

target_nameĀ eqĀ ā€œMarsā€Ā andĀ instrument_nameĀ eqĀ ā€œhiriseā€
alexdunnjpl commented 1 year ago

Agreed. @jordanpadams @tloubrieu-jpl do you have any suggestions for an example query that is meaningful/instructive and near-guaranteed to return a nonzero result set? Or should I just assume that what's in prod will always be and I can use what's currently there?

Presumably we want to link to the /properties endpoint in that part of the docs, once it's released.