In the built-in simple faceting, I get a Ruby response like this:

 'facet_counts'=>{
  'facet_queries'=>{},
  'facet_fields'=>{
        'subject_genre_facet'=>{
         'Biography.'=>2605,
         'Congresses.'=>1837,
         'Bibliography.'=>672,
         'Exhibitions.'=>642,
         'Periodicals.'=>615},
...

This is using &facet.limit=5 and no sort specified, so the items are being written in the proper order, however they are written as a Ruby Hash syntax, which does not iterate in a predictable order (like Java's Map). This really should be an Array in order for the client to assume the response is in a specified order. I think the response is best formatted as:

 'facet_counts'=>{
  'facet_queries'=>{},
  'facet_fields'=>{
        'subject_genre_facet'=>[
         {'Biography.'=>2605},
         {'Congresses.'=>1837},
         {'Bibliography.'=>672},
         {'Exhibitions.'=>642},
         {'Periodicals.'=>615}],
...

This makes the navigation of the results a bit clunkier because each item in a fields array is a single element Hash(Map), but the facets of a field really need to be in an array to maintain order.

I presume this same dilemma is in the Python/JSON format too? In XML, the <lst> has the right semantics, and a parser would easily be able to deal with it in order:

<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
  <lst name="subject_genre_facet">
        <int name="Biography.">2605</int>
        <int name="Congresses.">1837</int>
        <int name="Bibliography.">672</int>
        <int name="Exhibitions.">642</int>
        <int name="Periodicals.">615</int>
  </lst>
...

Thoughts?

        Erik

Reply via email to