Sha256: a6c6f29e24d24cedb0557b46e08af2e6cde2ac81eefed3a9e99803125b6c1e36

Contents?: true

Size: 1.13 KB

Versions: 43

Compression:

Stored size: 1.13 KB

Contents

module Sunspot
  module Query
    # 
    # Abstract class for function queries.
    #
    class FunctionQuery 
      include RSolr::Char
    end

    #
    # Function query which represents a constant.
    #
    class ConstantFunctionQuery < FunctionQuery
      def initialize(constant)
        @constant = constant
      end

      def to_s
        Type.to_literal(@constant)
      end
    end

    #
    # Function query which represents a field.
    #
    class FieldFunctionQuery < FunctionQuery
      def initialize(field)
        @field = field
      end

      def to_s
        "#{escape(@field.indexed_name)}"
      end
    end

    #
    # Function query which represents an actual function invocation.
    # Takes a function name and arguments as parameters.
    # Arguments are in turn FunctionQuery objects.
    #
    class FunctionalFunctionQuery < FunctionQuery
      def initialize(function_name, function_args)
        @function_name, @function_args = function_name, function_args
      end

      def to_s
        params = @function_args.map { |arg| arg.to_s }.join(",")
        "#{@function_name}(#{params})"
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 11 rubygems

Version Path
gojee-sunspot-2.0.5 lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.120925 lib/sunspot/query/function_query.rb
sunspot_solr-2.0.0.pre.120924 sunspot/lib/sunspot/query/function_query.rb
sunspot_rails-2.0.0.pre.120924 sunspot/lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.120924 sunspot/lib/sunspot/query/function_query.rb
gojee-sunspot-2.0.4 lib/sunspot/query/function_query.rb
gojee-sunspot-2.0.2 lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.120720 lib/sunspot/query/function_query.rb
sunspot-1.3.3 lib/sunspot/query/function_query.rb
sunspot-1.3.2 lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.120417 lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.120415 lib/sunspot/query/function_query.rb
sunspot-1.3.1 lib/sunspot/query/function_query.rb
erichummel-sunspot-2.0.0.pre.111215d lib/sunspot/query/function_query.rb
erichummel-sunspot-2.0.0.pre.111215c lib/sunspot/query/function_query.rb
erichummel-sunspot-2.0.0.pre.111215b lib/sunspot/query/function_query.rb
erichummel-sunspot-2.0.0.pre.111215a lib/sunspot/query/function_query.rb
erichummel-sunspot-2.0.0.pre.111215 lib/sunspot/query/function_query.rb
sunspot-2.0.0.pre.111215 lib/sunspot/query/function_query.rb
cb_sunspot-2.0.0.pre.5 lib/sunspot/query/function_query.rb