Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API search returns 500 for anything besides simple queries #259

Closed
msbentley opened this issue Apr 26, 2023 · 9 comments · Fixed by #263
Closed

API search returns 500 for anything besides simple queries #259

msbentley opened this issue Apr 26, 2023 · 9 comments · Fixed by #263
Assignees
Labels
B14.0 bug Something isn't working

Comments

@msbentley
Copy link

msbentley commented Apr 26, 2023

Checked for duplicates

No - I haven't checked

🐛 Describe the bug

Query string:

q='geom:Distances_Specific.geom:spacecraft_heliocentric_distance gt 160000000'

works fine, as does

q='geom:Distances_Specific.geom:spacecraft_heliocentric_distance lt 180000000'

however, this gives a 500 error:

q='geom:Distances_Specific.geom:spacecraft_heliocentric_distance gt 160000000 and geom:Distances_Specific.geom:spacecraft_heliocentric_distance lt 180000000'

I have tried adding brackets etc. but nothing seems to help here. I have tried queries also with or instead of and, substituting ge and le intsead of gt and lt but nothing seems to work.

🕵️ Expected behavior

I expected this search to succeed and yield results.

📜 To Reproduce

  1. Search as above. In my case I was using python/requests:
r = requests.get(pds_url + 'products',
    params={
        'limit': 10,
        'fields': 'geom:Distances_Specific.geom:spacecraft_heliocentric_distance',
        'q': 'geom:Distances_Specific.geom:spacecraft_heliocentric_distance gt 160000000 and geom:Distances_Specific.geom:spacecraft_heliocentric_distance lt 180000000'})

but I have also tried with various other tools.

🖥 Environment Info

No response

📚 Version of Software Used

No response

🩺 Test Data / Additional context

No response

🦄 Related requirements

🦄 #xyz

⚙️ Engineering Details

No response

@jordanpadams
Copy link
Member

@tloubrieu-jpl @alexdunnjpl can you verify this is fixed with the new version of the API coming out?

@alexdunnjpl
Copy link

@jordanpadams @msbentley do we have a known-broken version to ensure I can compare behaviour properly?

@msbentley
Copy link
Author

From my side I was testing with the live PDS endpoint (https://pds.nasa.gov/api/search/1/)

@tloubrieu-jpl
Copy link
Member

@msbentley I will look at your tests, but if that is quick on your side, you can replace your current endpoint with https://pds.nasa.gov/api/search-en-gamma/1/ where the latest stable version of the API service is deployed in beta.

@tloubrieu-jpl
Copy link
Member

tloubrieu-jpl commented Apr 27, 2023

Hi @msbentley , actually the q parsing is quite rigorous on the usage of brackets. There are needed everywhere you can think they can help (as in java, unlike python).
The q value which works in your case is:

    ((geom:Distances_Specific.geom:spacecraft_heliocentric_distance gt 160000000) and (geom:Distances_Specific.geom:spacecraft_heliocentric_distance lt 180000000))

We made that syntax choice to simplify the query parser which was developed to handle these complex queries. I will try to make the documentation more clear on that.

@alexdunnjpl
Copy link

@tloubrieu-jpl documentation aside, should I open a ticket to return a HTTP400 with a descriptive message on query parse failure?

@tloubrieu-jpl
Copy link
Member

Yes @alexdunnjpl that would be nice, I asked for that a while ago but we gave up on that, the ticket is still there NASA-PDS/registry-api#13 so no need to create a new one. You can re-evaluate the analysis which was done then. If feasible we can put that in our priorities again.

@msbentley
Copy link
Author

Aha, thanks @tloubrieu-jpl - it never would have occured to me to bracket the entire query string, given that a simple query doesn't need this - yes, extensive docs and examples would be great, for those of us who have never had to do battle in java ;-)

@tloubrieu-jpl
Copy link
Member

@msbentley I created a ticket NASA-PDS/registry-api#327 to see if we can make the parser a bit more lenient with brackets.

@alexdunnjpl alexdunnjpl added wontfix This will not be worked on and removed wontfix This will not be worked on labels May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B14.0 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants