On May 7, 2009, at 10:25 PM, David Shettler wrote:
I found myself with a real need for some of the StatsComponent stuff
(mainly the sum feature), so I pulled down a nightly build and played
with it. StatsComponent proved perfect, but... the nightly build
output seems to be different, and thus incompatible with acts_as_solr.
Could you give some more details on what seems different and
incompatible with acts_as_solr?
You can query the StatsComponent from Ruby using the solr-ruby
library. Using the example from the wiki at http://wiki.apache.org/solr/StatsComponent
, it points to http://localhost:8983/solr/select?q=*:*stats=truestats.field=pricestats.field=popularityrows=0indent=true
require 'solr'
solr = Solr::Connection.new
solr.send(Solr::Request::Select.new(:standard, :q = '*:*', :stats =
true, 'stats.field' = ['price','popularity'], :rows=0))
Which output this (in irb):
= #Solr::Response::Select:0x141692c @header={QTime=1,
params={stats=true, qt=standard, stats.field=[price,
popularity], q=*:*, rows=0, wt=ruby}, status=0},
@raw_response
=
{'responseHeader
'=
{'status
'=
0
,'QTime
'=
1
,'params
'=
{'stats
'=
'true
','q
'=
'*:*','stats
.field
'=
['price
','popularity
'],'qt
'=
'standard
','wt
'=
'ruby
','rows
'=
'0
'}},'response
'=
{'numFound
'=
26
,'start
'=
0
,'docs
'=
[]},'stats
'=
{'stats_fields
'=
{'price
'=
{'min
'=
0.0
,'max
'=
2199.0
,'sum
'=
5251.26995
,'count
'=
15
,'missing
'=
11
,'sumOfSquares
'=
6038619.160315
,'mean
'=
350.084664
,'stddev
'=
547.737557906113
},'popularity
'=
{'min
'=
0.0
,'max
'=
10.0
,'sum
'=
90.0
,'count
'=
26
,'missing
'=
0
,'sumOfSquares
'=628.0,'mean'=3.4615384615384617,'stddev'=3.5578731762756157,
@data={response={start=0, docs=[], numFound=26},
stats={stats_fields={price={sumOfSquares=6038619.1603,
sum=5251.27, max=2199.0, mean=350.0847, count=15,
stddev=547.737557906113, min=0.0, missing=11},
popularity={sumOfSquares=628.0, sum=90.0, max=10.0,
mean=3.46153846153846, count=26, stddev=3.55787317627562,
min=0.0, missing=0}}}, responseHeader={QTime=1,
params={stats=true, qt=standard, stats.field=[price,
popularity], q=*:*, rows=0, wt=ruby}, status=0}}
Is it possible, with some degree of effort (obviously) for me to
essentially port some of the functionality of StatsComponent to 1.3
myself? It's that, or waiting for 1.4 to come out and someone
developing support for it into acts_as_solr, or myself fixing what I
have for acts_as_solr to work with the output. I'm just trying to
gauge the easiest solution :)
I'm unclear on what what the discrepancies are, so not quite sure how
to help just yet.
As Eric asked, what version/branch of acts_as_solr are you using?
Erik