lib/riak/search/query.rb in riak-client-2.2.0.pre1 vs lib/riak/search/query.rb in riak-client-2.2.0
- old
+ new
@@ -1,11 +1,11 @@
require 'riak/search'
module Riak::Search
# A {Riak::Search::Query} wraps a Solr query for Riak Search 2.
class Query
-
+
# @!attribute rows
# @return [Numeric] the number of rows to return from the query
attr_accessor :rows
# @!attribute start
@@ -34,18 +34,26 @@
# @!attribute [r] term
# @return [String] the term to query
attr_reader :term
+ # @!attribute [r] index
+ # @return [Riak::Search::Index] the index to query against
+ attr_reader :index
+
+ # @!attribute [r] client
+ # @return [Riak::Client] the client to query against
+ attr_reader :client
+
# Initializes a query object.
#
# @param [Riak::Client] client the client connected to the Riak cluster
# @param [String,Riak::Search::Index] index the index to query, either a
# {Riak::Search::Index} instance or a {String}
# @param [String] term the query term
# @param [Hash] options a hash of options to quickly set attributes
- def initialize(client, index, term, options={ })
+ def initialize(client, index, term, options = { })
@client = client
validate_index index
@term = term
@options = options.symbolize_keys
@@ -61,11 +69,11 @@
@results = ResultCollection.new @client, raw_results
end
private
-
+
def index_name
return @index if @index.is_a? String
return @index.name
end
@@ -93,27 +101,27 @@
@filter = nil
@df = %w{text}
@op = nil
@fl = %w{_yz_rb _yz_rk _yz_rt score}
-
+
@presort = nil
end
def consume_options
@rows = @options[:rows] if @options[:rows]
@start = @options[:start] if @options[:start]
-
+
@sort = @options[:sort] if @options[:sort]
@filter = @options[:filter] if @options[:filter]
@df = @options[:df] if @options[:df]
@op = @options[:op] if @options[:op]
@fl = @options[:fl] if @options[:fl]
end
def prepare_options
- configured_options = {
+ configured_options = {
rows: @rows,
start: @start,
sort: @sort,
filter: @filter,
df: @df.join(' '),