cfpb / ccdb5-api

An API that provides an interface to search complaint data.
Creative Commons Zero v1.0 Universal
14 stars 16 forks source link

Hits.total for the `/` endpoint does not parse as an integer #179

Closed mwalker9 closed 3 years ago

mwalker9 commented 3 years ago

There seems to be a discrepancy between the Swagger documentation and the actual response object. The documentation indicates that Hits.total should parse as an integer.

In practice, for the / endpoint, I found that hits.total is an object that looks something like this:

{
            "value": 3198,
            "relation": "eq"
}

Example API call:

www.consumerfinance.gov/data-research/consumer-complaints/search/api/v1/?date_received_max=2021-09-15&date_received_min=2021-09-14

higs4281 commented 3 years ago

@mwalker9 Thanks for flagging this. Elasticsearch changed its API for delivering hit counts, and we adjusted our code to handle it but we need to update the Swagger docs to reflect that.

higs4281 commented 3 years ago

@mwalker9 FYI, our code always requests track_total_hits, which is less efficient but always returns the true hit count, even above 10,000 hits.
So hits.total.value should return what you were used to seeing in hits.total, and you can ignore Elasticsearch's "relation" value.

mwalker9 commented 3 years ago

Thank you for the info @higs4281