theoretick / discuss-it

online article discussion finder, DEPRECATED repo: https://gitlab.com/theoretick/discuss_it
http://www.discussitapp.com
Apache License 2.0
10 stars 3 forks source link

Add Exact matches to new Algolia HNSearch #74

Closed theoretick closed 10 years ago

theoretick commented 10 years ago

defaults to fuzzy matching. Fix that:

~/code/discuss-it master*
11:10:39 $ git diff
diff --git a/lib/discuss_it/fetchers.rb b/lib/discuss_it/fetchers.rb
index 748f9c1..12da698 100644
--- a/lib/discuss_it/fetchers.rb
+++ b/lib/discuss_it/fetchers.rb
@@ -218,7 +218,8 @@ module DiscussIt
       def initialize(query_url)
         @errors = []

-        hn_raw = get_response(api_url, query_url + '/')
+        full_query = "#{api_url}%22#{query_url}%22"
+        hn_raw = get_response(full_query)
         @raw_master = pull_out(hn_raw)
       end

@@ -232,6 +233,7 @@ module DiscussIt
       end

       def api_url
+        return 'http://hn.algolia.io/api/v1/search_by_date?tags=story&minWordSizefor1Typo=1000&minWordSizefor2Typos=1000&query='
         return 'http://hn.algolia.io/api/v1/search?tags=story&query='
       end

see https://github.com/algolia/hn-search/issues/28

theoretick commented 10 years ago

Closing. Fixed with https://github.com/theoretick/discuss-it/commit/45d4963ce53111c3c85b40ad8c1492dccfd1cd55