Class: Riak::Search::Query
Overview
A Query wraps a Solr query for Riak Search 2.
Instance Attribute Summary collapse
-
#client ⇒ Riak::Client
readonly
The client to query against.
-
#df ⇒ Array<String>
Default fields for Solr to search.
-
#filter ⇒ String
Have Solr filter the results prior to returning them.
-
#fl ⇒ Array<String>
Fields for Solr to return.
-
#index ⇒ Riak::Search::Index
readonly
The index to query against.
-
#op ⇒ String
Solr search operator.
-
#rows ⇒ Numeric
The number of rows to return from the query.
-
#sort ⇒ String
How Solr should sort the result set.
-
#start ⇒ Numeric
The offset into the total result set to get results for.
-
#term ⇒ String
readonly
The term to query.
Instance Method Summary collapse
-
#initialize(client, index, term, options = { }) ⇒ Query
constructor
Initializes a query object.
-
#results ⇒ Riak::Search::ResultCollection
Get results from the query.
Constructor Details
#initialize(client, index, term, options = { }) ⇒ Query
Initializes a query object.
54 55 56 57 58 59 60 61 62 |
# File 'lib/riak/search/query.rb', line 54 def initialize(client, index, term, = { }) @client = client validate_index index @term = term @options = .symbolize_keys set_defaults end |
Instance Attribute Details
#client ⇒ Riak::Client (readonly)
Returns the client to query against.
45 46 47 |
# File 'lib/riak/search/query.rb', line 45 def client @client end |
#df ⇒ Array<String>
Returns default fields for Solr to search.
25 26 27 |
# File 'lib/riak/search/query.rb', line 25 def df @df end |
#filter ⇒ String
Returns have Solr filter the results prior to returning them.
21 22 23 |
# File 'lib/riak/search/query.rb', line 21 def filter @filter end |
#fl ⇒ Array<String>
Returns fields for Solr to return.
33 34 35 |
# File 'lib/riak/search/query.rb', line 33 def fl @fl end |
#index ⇒ Riak::Search::Index (readonly)
Returns the index to query against.
41 42 43 |
# File 'lib/riak/search/query.rb', line 41 def index @index end |
#op ⇒ String
Returns Solr search operator.
29 30 31 |
# File 'lib/riak/search/query.rb', line 29 def op @op end |
#rows ⇒ Numeric
Returns the number of rows to return from the query.
9 10 11 |
# File 'lib/riak/search/query.rb', line 9 def rows @rows end |
#sort ⇒ String
Returns how Solr should sort the result set.
17 18 19 |
# File 'lib/riak/search/query.rb', line 17 def sort @sort end |
#start ⇒ Numeric
Returns the offset into the total result set to get results for.
13 14 15 |
# File 'lib/riak/search/query.rb', line 13 def start @start end |
#term ⇒ String (readonly)
Returns the term to query.
37 38 39 |
# File 'lib/riak/search/query.rb', line 37 def term @term end |
Instance Method Details
#results ⇒ Riak::Search::ResultCollection
Get results from the query. Performs the query when called the first time.
67 68 69 70 71 |
# File 'lib/riak/search/query.rb', line 67 def results return @results if defined? @results @results = ResultCollection.new @client, raw_results end |