Class: Sunspot::DSL::MoreLikeThisQuery

Inherits:
FieldQuery show all
Includes:
Adjustable, Paginatable
Defined in:
sunspot/lib/sunspot/dsl/more_like_this_query.rb

Overview

This class provides the DSL for MoreLikeThis queries.

Constant Summary

Constants inherited from Scope

NONE

Instance Method Summary (collapse)

Methods included from Adjustable

#adjust_solr_params, #request_handler

Methods included from Paginatable

#paginate

Methods inherited from FieldQuery

#dynamic, #facet, #initialize, #order_by, #order_by_random

Methods inherited from Scope

#all_of, #any_of, #dynamic, #initialize, #text_fields, #with, #without

Constructor Details

This class inherits a constructor from Sunspot::DSL::FieldQuery

Instance Method Details

- (Object) boost_by_relevance(should_boost) Also known as: boost



50
51
52
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 50

def boost_by_relevance(should_boost)
  @query.more_like_this.boost_by_relevance = should_boost
end

- (Object) fields(*field_names)



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 9

def fields(*field_names)
  boosted_fields = field_names.pop if field_names.last.is_a?(Hash)
  field_names.each do |name|
    mlt_fields = @setup.more_like_this_fields(name)
    raise(ArgumentError, "Field #{name} is not setup for more_like_this") if mlt_fields.empty?
    mlt_fields.each { |field| @query.more_like_this.add_field(field) }
  end
  if boosted_fields
    boosted_fields.each_pair do |field_name, boost|
      @setup.more_like_this_fields(field_name).each do |field|
        @query.more_like_this.add_field(field, boost)
      end
    end
  end
end

- (Object) maximum_query_terms(value) Also known as: maxqt



45
46
47
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 45

def maximum_query_terms(value)
  @query.more_like_this.maximum_query_terms = value
end

- (Object) maximum_word_length(value) Also known as: maxwl



40
41
42
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 40

def maximum_word_length(value)
  @query.more_like_this.maximum_word_length = value
end

- (Object) minimum_document_frequency(value) Also known as: mindf



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

def minimum_document_frequency(value)
  @query.more_like_this.minimum_document_frequency = value
end

- (Object) minimum_term_frequency(value) Also known as: mintf



25
26
27
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 25

def minimum_term_frequency(value)
  @query.more_like_this.minimum_term_frequency = value
end

- (Object) minimum_word_length(value) Also known as: minwl



35
36
37
# File 'sunspot/lib/sunspot/dsl/more_like_this_query.rb', line 35

def minimum_word_length(value)
  @query.more_like_this.minimum_word_length = value
end