You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Marcus Herou <ma...@tailsweep.com> on 2010/03/11 21:23:33 UTC

Abstractify FacetComponent and SimpleFacets

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.herou@tailsweep.com
http://www.tailsweep.com/

Re: Abstractify FacetComponent and SimpleFacets

Posted by Marcus Herou <ma...@tailsweep.com>.
Hi, thanks I wondered if it already was incorporated or such.

Yes it is a little related to StatsComponent ( sum, avg etc) but I think
that this solves another problem (correct me if I'm wrong) since it
transforms the resulting field in a functionquery instead of counting as per
default (today). I think that the StatsComponent does something similar but
operates on the resulting facet. I hook in earlier.

I used the StatsComponent as template for another component which I call
CountComponent (
http://svn.tailsweep.com/opensource/solr-contrib/trunk/src/main/java/org/apache/solr/handler/component/CountComponent.java)
which emulates the SQL equiv: "select count(distinct field)". Added the
"patch" to JIRA (https://issues.apache.org/jira/browse/SOLR-1814) That one
works with sharding as well. The problem is that one need to send the damn
entire unique hashset of field across the shards... (can get big). See that
Ted and Erik have commented now... Perhaps I have created something which
already exists... damn

Both these Components probably need to be refined for a release/merge into
Solr.

How do I move onward with these ?






On Fri, Mar 12, 2010 at 2:02 AM, Grant Ingersoll <gs...@apache.org>wrote:

>
> On Mar 11, 2010, at 6:30 PM, Yonik Seeley wrote:
>
> > Interesting looking stuff Marcus!
> > Seems sort of related to stat.facet (calc stats on unique facet values)
> > http://wiki.apache.org/solr/StatsComponent
>
> And https://issues.apache.org/jira/browse/SOLR-1622
>
> >
> >
> > On Thu, Mar 11, 2010 at 5:49 PM, Marcus Herou
> > <ma...@tailsweep.com> wrote:
> >> 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.
> >
> > Hoss was actually the first author of SimpleFacets - SOLR-44 (Solr
> > didn't even have built-in faceting when it came into the incubator!)
> >
> > -Yonik
> > http://www.lucidimagination.com
>
>
>


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

Re: Abstractify FacetComponent and SimpleFacets

Posted by Grant Ingersoll <gs...@apache.org>.
On Mar 11, 2010, at 6:30 PM, Yonik Seeley wrote:

> Interesting looking stuff Marcus!
> Seems sort of related to stat.facet (calc stats on unique facet values)
> http://wiki.apache.org/solr/StatsComponent

And https://issues.apache.org/jira/browse/SOLR-1622

> 
> 
> On Thu, Mar 11, 2010 at 5:49 PM, Marcus Herou
> <ma...@tailsweep.com> wrote:
>> 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.
> 
> Hoss was actually the first author of SimpleFacets - SOLR-44 (Solr
> didn't even have built-in faceting when it came into the incubator!)
> 
> -Yonik
> http://www.lucidimagination.com



Re: Abstractify FacetComponent and SimpleFacets

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Interesting looking stuff Marcus!
Seems sort of related to stat.facet (calc stats on unique facet values)
http://wiki.apache.org/solr/StatsComponent


On Thu, Mar 11, 2010 at 5:49 PM, Marcus Herou
<ma...@tailsweep.com> wrote:
> 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.

Hoss was actually the first author of SimpleFacets - SOLR-44 (Solr
didn't even have built-in faceting when it came into the incubator!)

-Yonik
http://www.lucidimagination.com

Re: Abstractify FacetComponent and SimpleFacets

Posted by Marcus Herou <ma...@tailsweep.com>.
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 <ma...@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.herou@tailsweep.com
> http://www.tailsweep.com/
>
>


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