: For now, if you want to integrate existing standard/dismax
: functionality, there is no great way to cleanly do this without copying

: You could almost do what you need by overriding getFacetInfo(), but you
: also need to check the DocList.


actually, for this use case i think overriding getFacetInfo is a perfectly
clean way to go about it (one of hte view parts of those request hadlers
that is easy to override) ... i'm not sure why you'd want the DocLIst for
this ... iterating over it will only get the matches on the current "page"
-- and if that's all you want stats for you might aswell do it on the
client side.  You can iterate over al lthe docs in the DocSet as well ...
but i would recommend using the FieldCache to get the indexed values
instead of using the stored values - and the ValueSource of your fieldtype
can make this really easy.

your handler would look something like...

public class MyHandler extends StandardRequestHandler {
  public void init(NamedList l) {
     /* parse any config options you want */
     super.init(l);
  }
  protected NamedList getFacetInfo(SolrQueryRequest req,
                                   SolrQueryResponse rsp,
                                   DocSet mainSet) {
     NamedList res = super.getFacetInto(req,rsp,mainSet);
     SchemaField field = /* get the field you want stats on from the 
IndexSchema */
     DocValues vals = 
field.getType().getValueSource(field).getValues(req.getSearcher().getReader());
     DocIter i = mainSet.iterator()
     while (i.hasNext()) {
        int val = vals.floatVal(i.next());
        /* do whatever you want with the value */
     }
     /* add your stats to res */
     return res;
   }
}


...that's it.


-Hoss

Reply via email to