mediacloud / news-search-api

Internal API server that offers search access to the Media Cloud Online News Archive (in Elasticsearch).
https://mediacloud.org
GNU Affero General Public License v3.0
1 stars 3 forks source link

search/results endpoint not working #33

Closed rahulbot closed 9 months ago

rahulbot commented 9 months ago

I'm trying to test out the API integration for paging through stories and can't get the search/results endpoint to work. It should return a page of matching stories, but instead just returns "Internal Server Error" on both production and staging.

I double checked the source code in api.py and I think I'm querying it properly: v1/mediacloud_search_text_*/search/result?q=biden.

Am I querying it wrong? Any way to see a more useful error message in a log file?

pgulley commented 9 months ago

Two things:

  1. For some reason, I'm not actually seeing an error logged on theindexer_news-search-api but I've reproduced this on staging, where I can see logs! @philbudne, any guesses about this?
  2. The error is:
File "/app/api.py", line 118, in encode
    return base64.b64encode(strng.encode(), b"-_").decode().replace("=", "~")
    AttributeError: 'int' object has no attribute 'encode'

It looks like the issue has to do with grabbing the paging token, in _search_result- I'll have to jump in tomorrow to see what's at the bottom of this.

philbudne commented 9 months ago

@pgulley asked:

  1. For some reason, I'm not actually seeing an error logged on theindexer_news-search-api but I've reproduced this on staging, where I can see logs! @philbudne, any guesses about this?

Only that sometimes "docker logs CONTAINERID" returns stuff that "docker service logs SERVICENAME" doesn't...

p

rahulbot commented 9 months ago

If you cherry-pick e44ebc6 from the unit testing branch (or make the same 1-line fix) that will fix this bug. That branch has a unit test showing a page being generated with a token for the next page.

rahulbot commented 9 months ago

I fixed this by merging that PR