konklone / congress-android

Congress for Android, an app for tracking Congress.
https://play.google.com/store/apps/details?id=com.sunlightlabs.android.congress
Other
157 stars 43 forks source link

Highlighted search excerpts alongside text search results #685

Closed konklone closed 7 years ago

konklone commented 7 years ago

When returning search results for bills that match a keyword, it'd be a huge improvement to return the excerpts of text matches. ElasticSearch provides this, and it really helps to be able to provide users with the context of why a match was a match.

The Sunlight Congress API provided this function, along with the ability to customize the HTML tag used to surround the highlighted keyword: https://sunlightlabs.github.io/congress/#highlighting

To see an example (no API key needed, apparently): https://congress.api.sunlightfoundation.com/bills/search?query=health&highlight=true

Note that in the above example, the highlighted text can appear in multiple fields, and the API returns all of the matched fields. That's not strictly necessary, but can help clients manage display in a more granular fashion.

Customizing the highlight tag is also not strictly necessary, though without that, the client may need to do some ugly munging to find the matches and/or replace the tag with whatever relevant tags it needs for its environment.

konklone commented 7 years ago

Meant to file at https://github.com/propublica/congress-api-docs/issues/54