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:



68
69
70
71
72
73
74
75
76
# File 'lib/riak/search/query.rb', line 68

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:



59
60
61
# File 'lib/riak/search/query.rb', line 59

def client
  @client
end

#dfArray<String>

Returns default fields for Solr to search.

Returns:

  • (Array<String>)

    default fields for Solr to search



39
40
41
# File 'lib/riak/search/query.rb', line 39

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



35
36
37
# File 'lib/riak/search/query.rb', line 35

def filter
  @filter
end

#flArray<String>

Returns fields for Solr to return.

Returns:



47
48
49
# File 'lib/riak/search/query.rb', line 47

def fl
  @fl
end

#indexRiak::Search::Index (readonly)

Returns the index to query against.

Returns:



55
56
57
# File 'lib/riak/search/query.rb', line 55

def index
  @index
end

#opString

Returns Solr search operator.

Returns:

  • (String)

    Solr search operator



43
44
45
# File 'lib/riak/search/query.rb', line 43

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



23
24
25
# File 'lib/riak/search/query.rb', line 23

def rows
  @rows
end

#sortString

Returns how Solr should sort the result set.

Returns:

  • (String)

    how Solr should sort the result set



31
32
33
# File 'lib/riak/search/query.rb', line 31

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



27
28
29
# File 'lib/riak/search/query.rb', line 27

def start
  @start
end

#termString (readonly)

Returns the term to query.

Returns:

  • (String)

    the term to query



51
52
53
# File 'lib/riak/search/query.rb', line 51

def term
  @term
end

Instance Method Details

#resultsRiak::Search::ResultCollection

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

Returns:



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