Class: Elastify::Helpers::ElasticSearch::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/elastify/helpers/elastic_search/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elasticsearch_search_result_hit, elastify_options) ⇒ SearchResult

Returns a new instance of SearchResult.



8
9
10
11
12
13
14
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 8

def initialize(elasticsearch_search_result_hit, elastify_options)
    @index = elasticsearch_search_result_hit["_index"]
    @type = elasticsearch_search_result_hit["_type"]
    @id = elasticsearch_search_result_hit["_id"]
    @source = elasticsearch_search_result_hit["_source"]
    @elastify_options = elastify_options
end

Instance Attribute Details

#elastify_optionsObject

Returns the value of attribute elastify_options.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def elastify_options
  @elastify_options
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def id
  @id
end

#indexObject

Returns the value of attribute index.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def index
  @index
end

#scoreObject

Returns the value of attribute score.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def score
  @score
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def source
  @source
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 5

def type
  @type
end

Instance Method Details

#decodeObject



16
17
18
19
20
21
22
# File 'lib/elastify/helpers/elastic_search/search_result.rb', line 16

def decode
    data = {}
    if @elastify_options[:decode]
        data = @elastify_options[:decode].call(@source)
    end
    return data
end