Class: Sunspot::DSL::MoreLikeThisQuery

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

Overview

This class provides the DSL for MoreLikeThis queries.

Constant Summary

Constants inherited from Scope

Scope::NONE

Instance Method Summary collapse

Methods included from Paginatable

#paginate

Methods included from Adjustable

#adjust_solr_params, #request_handler

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

#boost_by_relevance(should_boost) ⇒ Object Also known as: boost



50
51
52
# File '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

#fields(*field_names) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File '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

#maximum_query_terms(value) ⇒ Object Also known as: maxqt



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

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

#maximum_word_length(value) ⇒ Object Also known as: maxwl



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

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

#minimum_document_frequency(value) ⇒ Object Also known as: mindf



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

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

#minimum_term_frequency(value) ⇒ Object Also known as: mintf



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

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

#minimum_word_length(value) ⇒ Object Also known as: minwl



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

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