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.
68 69 70 71 72 73 74 75 76 |
# File 'lib/riak/search/query.rb', line 68 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.
59 60 61 |
# File 'lib/riak/search/query.rb', line 59 def client @client end |
#df ⇒ Array<String>
Returns default fields for Solr to search.
39 40 41 |
# File 'lib/riak/search/query.rb', line 39 def df @df end |
#filter ⇒ String
Returns have Solr filter the results prior to returning them.
35 36 37 |
# File 'lib/riak/search/query.rb', line 35 def filter @filter end |
#fl ⇒ Array<String>
Returns fields for Solr to return.
47 48 49 |
# File 'lib/riak/search/query.rb', line 47 def fl @fl end |
#index ⇒ Riak::Search::Index (readonly)
Returns the index to query against.
55 56 57 |
# File 'lib/riak/search/query.rb', line 55 def index @index end |
#op ⇒ String
Returns Solr search operator.
43 44 45 |
# File 'lib/riak/search/query.rb', line 43 def op @op end |
#rows ⇒ Numeric
Returns the number of rows to return from the query.
23 24 25 |
# File 'lib/riak/search/query.rb', line 23 def rows @rows end |
#sort ⇒ String
Returns how Solr should sort the result set.
31 32 33 |
# File 'lib/riak/search/query.rb', line 31 def sort @sort end |
#start ⇒ Numeric
Returns the offset into the total result set to get results for.
27 28 29 |
# File 'lib/riak/search/query.rb', line 27 def start @start end |
#term ⇒ String (readonly)
Returns the term to query.
51 52 53 |
# File 'lib/riak/search/query.rb', line 51 def term @term end |
Instance Method Details
#results ⇒ Riak::Search::ResultCollection
Get results from the query. Performs the query when called the first time.
81 82 83 84 85 |
# File 'lib/riak/search/query.rb', line 81 def results return @results if defined? @results @results = ResultCollection.new @client, raw_results end |