Module: HackerNewsSearch::Client::Search

Included in:
HackerNewsSearch::Client
Defined in:
lib/hacker_news_search/client/search.rb

Instance Method Summary collapse

Instance Method Details

#hotness(options = {}) ⇒ Hash

Returns the top 30 hot stories based on the Hacker News Search algorithm

Examples:

HackerNewsSearch.hotness

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hash)

See Also:



27
28
29
# File 'lib/hacker_news_search/client/search.rb', line 27

def hotness(options={})
  get("items/_search?limit=30&sortby=product(points,pow(2,div(div(ms(create_ts,NOW),3600000),72)))%20desc", options)
end

#search(collection, query, options = {}) ⇒ Hash

Returns the information based on the search criteria

Examples:

HackerNewsSearch.search("users" "sferik")
HackerNewsSearch.search("users", "sferik" {:limit => "30"})
HackerNewsSearch.search("items" "jobs")

Parameters:

  • collection (String)

    collection is either - users or items

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

  • (Hash)

See Also:



16
17
18
# File 'lib/hacker_news_search/client/search.rb', line 16

def search(collection, query, options={})
  get("#{collection}/_search?q=#{query}", options)
end