Module: Sunspot::DSL::Adjustable

Included in:
MoreLikeThisQuery, StandardQuery
Defined in:
sunspot/lib/sunspot/dsl/adjustable.rb

Overview

:nodoc

Instance Method Summary (collapse)

Instance Method Details

- (Object) adjust_solr_params(&block)

Expert: Adjust or reset the parameters passed to Solr. The adjustment will take place just before sending the params to solr, after Sunspot builds the Solr params based on the methods called in the DSL.

Under normal circumstances, using this method should not be necessary; if you find that it is, please consider submitting a feature request. Using this method requires knowledge of Sunspot’s internal Solr schema and Solr query representations, which are not part of Sunspot’s public API; they could change at any time. This method is unsupported and your mileage may vary.

Examples

  Sunspot.search(Post) do
    adjust_solr_params do |params|
      params[:q] += ' AND something_s:more'
    end
  end

  Sunspot.more_like_this(my_post) do
    adjust_solr_params do |params|
      params["mlt.match.include"] = true
    end
  end


30
31
32
# File 'sunspot/lib/sunspot/dsl/adjustable.rb', line 30

def adjust_solr_params( &block )
  @query.solr_parameter_adjustment = block
end

- (Object) request_handler(request_handler)

Expert: Use a custom request handler for this search. The general use case for this would be a request handler configuration you’ve defined in solrconfig that has different search components, defaults, etc. Using this to point at an entirely different type of request handler that Sunspot doesn’t support probably won’t get you very far.



42
43
44
# File 'sunspot/lib/sunspot/dsl/adjustable.rb', line 42

def request_handler(request_handler)
  @search.request_handler = request_handler
end