Class: Stellr::Search::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/stellr/search/search_result.rb

Overview

A single search result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, score, field_data) ⇒ SearchResult

Returns a new instance of SearchResult.



8
9
10
11
12
# File 'lib/stellr/search/search_result.rb', line 8

def initialize(id, score, field_data)
  @doc_id = id
  @score = score
  @field_data = field_data
end

Instance Attribute Details

#doc_idObject (readonly)

Returns the value of attribute doc_id.



6
7
8
# File 'lib/stellr/search/search_result.rb', line 6

def doc_id
  @doc_id
end

#scoreObject (readonly)

Returns the value of attribute score.



6
7
8
# File 'lib/stellr/search/search_result.rb', line 6

def score
  @score
end

Instance Method Details

#field(name) ⇒ Object Also known as: []

retrieve contents of the field name



15
16
17
# File 'lib/stellr/search/search_result.rb', line 15

def field(name)
  @field_data[name]
end

#to_jsonObject



20
21
22
23
24
25
26
# File 'lib/stellr/search/search_result.rb', line 20

def to_json
  {
    :doc_id => @doc_id,
    :score => @score,
    :data => @field_data
  }.to_json
end