I have now implemented Facet with FunctionQueries it is really cool! Sorry
but even though the author of SimpleFacets (Yonik) says in the javadoc that
one should subclass it to leverage more functionality I did not really find
that very true in this case. Too much code that not could be templatified
easily. So... I crtl-c'd it... = very bad by me.

I have added very few quite trivial lines of code that should be generic
enough to be put into Solr core or into contrib after some basic tweaking by
a committer perhaps.

Added two new features.

1. facet.innerFunction (support for all SOLR function queries)
  extracts the ValueSource from the parsed FunctionQuery and foreach doc in
the faceted range search result returns the double value for that query and
passes it on to the outerFunction

2. facet.outerFunction - proprietary function support, currently only sum &
avg (before I implement the whole java.lang.Math package I need to verify
that it is not done before and in a much better way, probably function
chaining is needed as well i.e. product(a, sum(b,c)) )
  Very trivial - just collects the innerFunction retvals and for instance
sums them or average them. The result of this method is returned instead of
the default counting of docs as per default in the previous SimpleFacets
(which I ctrl-c'd into FunctionFacets


Example:

GET "
http://127.0.0.1:8110/solr/blogosphere-sv-2010Q1/select?q=*:*&rows=0&indent=on&facet=true&facet.date=publishedDate&facet.date.start=NOW/DAY-30DAYS&facet.date.end=NOW/DAY%2B1DAY&facet.date.gap=%2B1DAY&;
*facet.outerFunction=sum&facet.innerFunction=blogRank*"

Can be found here
http://svn.tailsweep.com/opensource/solr-contrib/trunk/src/main/java/org/apache/solr/handler/component/

Cheers

//Marcus


On Thu, Mar 11, 2010 at 9:23 PM, Marcus Herou <marcus.he...@tailsweep.com>wrote:

> I would like to utilize all code that has been written around Facets and
> just to hook in somewhere SimpleFacets.getFacetDateCounts calls rangeCount
> i.e. I would like to group on date but return something else than a count in
> this case the sum of another field than the actual faceted field but I feel
> that the generic way would be to be able to hook in a FunctionQuery somehow
> there.
>
> So what I try to say instead of ctrl-c those two classes I would like to
> refactor it somehow so I can use a template pattern or such here. Should I
> write the patch and would it be accepted by the community if it is written
> good ?
>
>
> Cheers
>
> //Marcus
>
>
>
>
>
> --
> Marcus Herou CTO and co-founder Tailsweep AB
> +46702561312
> marcus.he...@tailsweep.com
> http://www.tailsweep.com/
>
>


-- 
Marcus Herou CTO and co-founder Tailsweep AB
+46702561312
marcus.he...@tailsweep.com
http://www.tailsweep.com/

Reply via email to