Sha256: d3969e8857b4e0a01a20fd11327b372a49a0b763b92f1f376b98f7b0f75b5eb2
Contents?: true
Size: 1.4 KB
Versions: 9
Compression:
Stored size: 1.4 KB
Contents
module Sunspot module DSL class FieldGroup def initialize(setup, group) @setup, @group = setup, group end # # Sets the number of results (documents) to return for each group. # Defaults to 1. # def limit(num) @group.limit = num end # # If set, facet counts are based on the most relevant document of # each group matching the query. # # Supported in Solr 3.4 and above. # # ==== Example # # Sunspot.search(Post) do # group :title do # truncate # end # # facet :title, :extra => :any # end # def truncate @group.truncate = true end # Specify the order that results should be returned in. This method can # be called multiple times; precedence will be in the order given. # # ==== Parameters # # field_name<Symbol>:: the field to use for ordering # direction<Symbol>:: :asc or :desc (default :asc) # def order_by(field_name, direction = nil) sort = if special = Sunspot::Query::Sort.special(field_name) special.new(direction) else Sunspot::Query::Sort::FieldSort.new( @setup.field(field_name), direction ) end @group.add_sort(sort) end end end end
Version data entries
9 entries across 9 versions & 3 rubygems