Disjunctive Facet values are not ordered on devices below API 21
Closed this issue · 1 comments
We return the response as a JSONObject
crafted by iterating on JSONObject#keys()
, which specifies:
The order of the keys is undefined.
Apparently the key order matches the response's starting with API 21, but not before, resulting in an inconsistent ordering between API < 21 and API >= 21.
This is not a bug per se, as the JSON Standard defines a JSON Object as an unordered set of name/value pairs. Still, as we return the disjunctive facets ordered by decreasing facet count, it would be nice to keep this order when returning the data.
This problem could be solved by returning a more strongly-typed object in searchDisjunctiveFacetingAsync
.
After further discussion on this topic, the "right" ordering for facet values depends too much on the use-case for us to provide a default one as it would not be useful to most customers.
Developers should reorder the values using an ordered Collection
, or use InstantSearch Android whose RefinementList widget provides a sortBy
attribute where one can specify the desired ordering.