0.01
No commit activity in last 3 years
No release in over 3 years
Sunspot is a library providing a powerful, all-ruby API for the Solr search engine. This gem extend sunspot adding the statsComponent feature, which returns simple statistics for indexed numeric fields within the DocSet.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
 Project Readme

Sunspot Stats

Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. I use the latest version 2.1.0 but i need the statsComponent in order to get the sum (min, max, count, sumOfSquares, mean, stddev) on a given indexed field.

Installation

Add this line to your application's Gemfile:

gem 'sunspot_stats'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sunspot_stats

Usage

The statComponent let you to have min, max, count, missing, sum, sumOfsquare, mean and stdev.

An usage example

Model.search do
  #Filters
	...
  #Facets
  ...
	#Stats
  stat(:your_field, :facet => :your_facet_filed, :type => "min")  
  ...
end

:facet and :type are optional the default type is the "sum" (you can pass: min, max, count, missing, sum, sumOfsquare, mean, stdev as string)

Remember to stats on a non multi valued field and update to the solr3.6, because the solr3.5 has a bug with stats.

the Sunspot::SearchStatRow has the method stat_field and the value.

If you enable faceting on stats the stat_field is the facet and the value is the type defined.

Upgrade solr in sunspot

StatsComponent Notes

The facet field can be selectively applied. That is if you want stats on field "A" and "B", you can facet a on "X" and B on "Y" using &stats.field=A&f.A.stats.facet=X&stats.field=B&f.B.stats.facet=Y

Warning, as implemented, all facet results are returned, be careful what fields you ask for!

Multi-valued fields and facets may be slow.

StatsComponent

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request