Sha256: 04ae3a4ec5ef6b1b1eee2e2041a2215639618602b0720f8592de48334758d63f

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module Sunspot
  module Query
    class StandardQuery < CommonQuery
      attr_accessor :scope, :fulltext

      def initialize(types)
        super
        @components << @fulltext = Conjunction.new
      end

      def add_fulltext(keywords)
        @fulltext.add_fulltext(keywords)
      end

      def add_join(keywords, target, from, to)
        @fulltext.add_join(keywords, target, from, to)
      end

      def add_boost_query(factor)
        @fulltext.add_boost_query(factor)
      end

      def add_boost_function(function)
        @fulltext.add_boost_function(function)
      end

      def add_multiplicative_boost_function(function)
        @fulltext.add_multiplicative_boost_function(function)
      end

      def disjunction
        parent_fulltext = @fulltext
        @fulltext = @fulltext.add_disjunction

        yield
      ensure
        @fulltext = parent_fulltext
      end

      def conjunction
        parent_fulltext = @fulltext
        @fulltext = @fulltext.add_conjunction

        yield
      ensure
        @fulltext = parent_fulltext
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunspot-2.7.1 lib/sunspot/query/standard_query.rb
sunspot-2.7.0 lib/sunspot/query/standard_query.rb
sunspot-2.6.0 lib/sunspot/query/standard_query.rb