Class: Elastify::Helpers::ElasticSearch::SearchResultCollection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elasticsearch_search_result, elastify_options) ⇒ SearchResultCollection

Returns a new instance of SearchResultCollection.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/elastify/helpers/elastic_search/search_result_collection.rb', line 8

def initialize(elasticsearch_search_result, elastify_options)
    esr = JSON.parse(elasticsearch_search_result)
    @scroll_id = esr["_scroll_id"]
    @took = esr["took"]
    @timed_out = esr["timed_out"]
    @shards_total = esr["_shards"]["total"]
    @shards_successful = esr["_shards"]["successful"]
    @shards_failed = esr["_shards"]["failed"]
    @hits_total = esr["hits"]["total"]
    @hits_maxscore = esr["hits"]["maxscore"]
    @hits = esr["hits"]["hits"].map{ |hit| Elastify::Helpers::ElasticSearch::SearchResult.new(hit, elastify_options) }
    @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_collection.rb', line 5

def elastify_options
  @elastify_options
end

#hitsObject

Returns the value of attribute hits.



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

def hits
  @hits
end

#hits_maxscoreObject

Returns the value of attribute hits_maxscore.



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

def hits_maxscore
  @hits_maxscore
end

#hits_totalObject

Returns the value of attribute hits_total.



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

def hits_total
  @hits_total
end

#scroll_idObject

Returns the value of attribute scroll_id.



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

def scroll_id
  @scroll_id
end

#shards_failedObject

Returns the value of attribute shards_failed.



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

def shards_failed
  @shards_failed
end

#shards_successfulObject

Returns the value of attribute shards_successful.



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

def shards_successful
  @shards_successful
end

#shards_totalObject

Returns the value of attribute shards_total.



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

def shards_total
  @shards_total
end

#timed_outObject

Returns the value of attribute timed_out.



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

def timed_out
  @timed_out
end

#tookObject

Returns the value of attribute took.



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

def took
  @took
end