Class: Riak::Search::Query

Inherits:
Object show all
Defined in:
lib/riak/search/query.rb

Overview

A Query wraps a Solr query for Riak Search 2.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, index, term, options = { }) ⇒ Query

Initializes a query object.

Parameters:


54
55
56
57
58
59
60
61
62
# File 'lib/riak/search/query.rb', line 54

def initialize(client, index, term, options = {  })
  @client = client
  validate_index index
  @term = term
  @options = options.symbolize_keys

  set_defaults
  consume_options
end

Instance Attribute Details

#clientRiak::Client (readonly)

Returns the client to query against

Returns:


45
46
47
# File 'lib/riak/search/query.rb', line 45

def client
  @client
end

#dfArray<String>

Returns default fields for Solr to search

Returns:

  • (Array<String>)

    default fields for Solr to search


25
26
27
# File 'lib/riak/search/query.rb', line 25

def df
  @df
end

#filterString

Returns have Solr filter the results prior to returning them

Returns:

  • (String)

    have Solr filter the results prior to returning them


21
22
23
# File 'lib/riak/search/query.rb', line 21

def filter
  @filter
end

#flArray<String>

Returns fields for Solr to return

Returns:


33
34
35
# File 'lib/riak/search/query.rb', line 33

def fl
  @fl
end

#indexRiak::Search::Index (readonly)

Returns the index to query against

Returns:


41
42
43
# File 'lib/riak/search/query.rb', line 41

def index
  @index
end

#opString

Returns Solr search operator

Returns:

  • (String)

    Solr search operator


29
30
31
# File 'lib/riak/search/query.rb', line 29

def op
  @op
end

#rowsNumeric

Returns the number of rows to return from the query

Returns:

  • (Numeric)

    the number of rows to return from the query


9
10
11
# File 'lib/riak/search/query.rb', line 9

def rows
  @rows
end

#sortString

Returns how Solr should sort the result set

Returns:

  • (String)

    how Solr should sort the result set


17
18
19
# File 'lib/riak/search/query.rb', line 17

def sort
  @sort
end

#startNumeric

Returns the offset into the total result set to get results for

Returns:

  • (Numeric)

    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

#termString (readonly)

Returns the term to query

Returns:

  • (String)

    the term to query


37
38
39
# File 'lib/riak/search/query.rb', line 37

def term
  @term
end

Instance Method Details

#resultsRiak::Search::ResultCollection

Get results from the query. Performs the query when called the first time.

Returns:


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