mlehman / solrclj

A Clojure client for Apache Solr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

facet_fields are not ordered correctly

mwmitchell opened this issue · comments

A sample response from solrclj:

{:facet_counts {:facet_ranges nil, :facet_dates nil, :facet_fields {:type {:meta 1, :location 3, :hotel 48, :amenity 104, :landmark 1219}}}

The ordering of the :facet_fields should be by hit value like:

{:facet_counts {:facet_ranges nil, :facet_dates nil, :facet_fields {:type {:landmark 1219 :amenity 104 :hotel 48 :location 3 :meta 1}}}

Could this be converted to a sorted hash or just a list?

Here's a bit of helper code I used for handling this:

(defn create-facet-map [facet](hash-map :name %28.getName facet%29
:values %28reduce #%28assoc %1 %28.getName %2%29 %28.getCount %2%29 %29
{}
%28.getValues facet%29%29))

(defn create-facets-maps [facets](map create-facet-map facets))

I sent a pull request that fixes this problem: https://github.com/mwmitchell/solrclj/tree/response-mods