You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Yevgeniy Belman <ys...@gmail.com> on 2009/01/08 05:19:09 UTC

Amount range and facet fields returns [facet_fields]

Hi,

I am curious if this is expected behavior in a typical facet with range
query:
params={facet=true,facet.query=[price:[* TO 500], price:[500 TO
*]],q=*:*,facet.field=price

i am getting back not only the:
facet_queries={price:[* TO 500]=2,price:[500 TO *]=3}

but also:
facet_fields={price={150.99=1,199.99=1,699.99=1,930.0=1,2300.0=1}

I was searching for a way to create the elusive "dynamic" amount ranges, and
this would allow me to do it on the client side for sure, but is this right?
Solr will send all of this data back? It consists of every price variant
with a count. In my case 5 prices were all unique. If real data were used
could this be too big to send across?

SimpleFacet.getFacetCounts() populates the response object with it. Is this
an appropriate place to calculate my dymic amount ranges and replace
facet_fields:
res.add("facet_queries", getFacetQueryCounts());
res.add("facet_fields", getFacetFieldCounts()); // <-- replace with
"Dynamic" facets
res.add("facet_dates", getFacetDateCounts());

or should it be done sooner, somewhere in getFieldCacheCounts() where the
itteration through all the 5 docs is happening?

Thanks,
Yev

Re: Amount range and facet fields returns [facet_fields]

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jan 8, 2009, at 9:29 AM, Yevgeniy Belman wrote:
> the response i get when executing only the following, produces no  
> facet
> counts. It could be a bug.
>
> facet.query=[price:[* TO 500], price:[500 TO *]

That's an invalid query.  If you want two ranges, use two facet.query  
parameters.

	Erik


Re: Amount range and facet fields returns [facet_fields]

Posted by Yevgeniy Belman <ys...@gmail.com>.
Ah ok,

the response i get when executing only the following, produces no facet
counts. It could be a bug.

facet.query=[price:[* TO 500], price:[500 TO *]



However, when i add an unrelated facet field, i do get the desired count:

query=[price:[* TO 500], price:[500 TO *]],q=*:*,facet.field=cat

output:

price:[* TO 500]:2

price:[500 TO *]:3



Looking at StatsComponent i can't see a way to produce this result:

for given price set (150.99,199.99,699.99,930.0,2300.0),

output:

price:[150.99 TO 199.99]:2

price:[699.99 TO 930.0]:2

price:[930.0 TO 2300.0]:1



That is if I wanted to produce up-to three price ranges. Example:

http://www.tigerdirect.com/applications/category/category_slc.asp?CatId=2775&name=22-LCD-Monitor&



Thanks,

Yev.


On Thu, Jan 8, 2009 at 12:21 AM, Shalin Shekhar Mangar <
shalinmangar@gmail.com> wrote:

> On Thu, Jan 8, 2009 at 9:49 AM, Yevgeniy Belman <ys...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I am curious if this is expected behavior in a typical facet with range
> > query:
> > params={facet=true,facet.query=[price:[* TO 500], price:[500 TO
> > *]],q=*:*,facet.field=price
> >
> > i am getting back not only the:
> > facet_queries={price:[* TO 500]=2,price:[500 TO *]=3}
> >
> > but also:
> > facet_fields={price={150.99=1,199.99=1,699.99=1,930.0=1,2300.0=1}
>
>
> You are adding both facet.query=price[... and the facet.field=price
> parameters so the response contains results for both.
>
> I was searching for a way to create the elusive "dynamic" amount ranges,
> and
> > this would allow me to do it on the client side for sure, but is this
> > right?
> > Solr will send all of this data back? It consists of every price variant
> > with a count. In my case 5 prices were all unique. If real data were used
> > could this be too big to send across?
> >
> > SimpleFacet.getFacetCounts() populates the response object with it. Is
> this
> > an appropriate place to calculate my dymic amount ranges and replace
> > facet_fields:
> > res.add("facet_queries", getFacetQueryCounts());
> > res.add("facet_fields", getFacetFieldCounts()); // <-- replace with
> > "Dynamic" facets
> > res.add("facet_dates", getFacetDateCounts());
> >
> > or should it be done sooner, somewhere in getFieldCacheCounts() where the
> > itteration through all the 5 docs is happening?
> >
>
> By dynamic ranges, do you mean that you want min and max values? If yes,
> you
> can look at StatsComponent (it is a 1.4 feature, so you'll need to use the
> nightly builds).
>
> http://wiki.apache.org/solr/StatsComponent
>
> --
> Regards,
> Shalin Shekhar Mangar.
>

Re: Amount range and facet fields returns [facet_fields]

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Thu, Jan 8, 2009 at 9:49 AM, Yevgeniy Belman <ys...@gmail.com> wrote:

> Hi,
>
> I am curious if this is expected behavior in a typical facet with range
> query:
> params={facet=true,facet.query=[price:[* TO 500], price:[500 TO
> *]],q=*:*,facet.field=price
>
> i am getting back not only the:
> facet_queries={price:[* TO 500]=2,price:[500 TO *]=3}
>
> but also:
> facet_fields={price={150.99=1,199.99=1,699.99=1,930.0=1,2300.0=1}


You are adding both facet.query=price[... and the facet.field=price
parameters so the response contains results for both.

I was searching for a way to create the elusive "dynamic" amount ranges, and
> this would allow me to do it on the client side for sure, but is this
> right?
> Solr will send all of this data back? It consists of every price variant
> with a count. In my case 5 prices were all unique. If real data were used
> could this be too big to send across?
>
> SimpleFacet.getFacetCounts() populates the response object with it. Is this
> an appropriate place to calculate my dymic amount ranges and replace
> facet_fields:
> res.add("facet_queries", getFacetQueryCounts());
> res.add("facet_fields", getFacetFieldCounts()); // <-- replace with
> "Dynamic" facets
> res.add("facet_dates", getFacetDateCounts());
>
> or should it be done sooner, somewhere in getFieldCacheCounts() where the
> itteration through all the 5 docs is happening?
>

By dynamic ranges, do you mean that you want min and max values? If yes, you
can look at StatsComponent (it is a 1.4 feature, so you'll need to use the
nightly builds).

http://wiki.apache.org/solr/StatsComponent

-- 
Regards,
Shalin Shekhar Mangar.