api
api copied to clipboard
Fix multiple bugs in confidence score handling
There were multiple issues with the fallback query confidence score calculation middleware.
- Incorrect detection of handled query types. Essentially, the logic was negated
- Incorrect list of supported query types. Not all list entries matched the actual query names
- Incorrect parameter in mock data for unit tests. This combined with the first bug to mask the issue in unit tests
Fixes https://github.com/pelias/api/issues/1280
Looking at the acceptance test output, merging this might actually be problematic. It turns out a large number of queries return confidence scores from the newer, confidenceScoreFallback
middleware. This middleware sets the match_type
property (to, for example, exact
, fallback
or interpolated
).
We already identified in https://github.com/pelias/pelias/issues/739 that the inconsistency in returning the match_type
property is problematic for API consumers. Unfortunately, this would make that problem more prevalent.
It might be nice to figure out a reasonable way to set match_type
for all queries before merging this.
Additionally, the confidence score detection in confidenceScoreFallback
is "better": it returns 1
for exact matches that are truly correct a lot more frequently.
Combining the two middleware modules might be a win for behavior and code complexity (similar to https://github.com/pelias/api/pull/1314).