[Groonga-commit] ranguba/epub-searcher at 2d530fa [master] Make it possible to filter by authors

Back to archive index

KITAITI Makoto null+****@clear*****
Tue Sep 22 03:07:09 JST 2015


KITAITI Makoto	2015-09-22 03:07:09 +0900 (Tue, 22 Sep 2015)

  New Revision: 2d530fa0cdebffa1f632a7e0ee7daad9268252b0
  https://github.com/ranguba/epub-searcher/commit/2d530fa0cdebffa1f632a7e0ee7daad9268252b0

  Message:
    Make it possible to filter by authors

  Modified files:
    app/app.rb

  Modified: app/app.rb (+8 -3)
===================================================================
--- app/app.rb    2015-09-22 01:53:44 +0900 (b027663)
+++ app/app.rb    2015-09-22 03:07:09 +0900 (d5f7e1c)
@@ -58,9 +58,9 @@ module EPUBSearcher
     #   end
     #
 
-    def search_from_groonga(query_words)
+    def search_from_groonga(query_words, options = {})
       begin
-        db.select(
+        params = {
           :table => :Books,
           :query => query_words,
           :match_columns => 'author,title,main_text',
@@ -69,7 +69,12 @@ module EPUBSearcher
           :drilldown => 'author',
           :drilldown_output_columns => '_key,_nsubrecs',
           :drilldown_limit => -1
-        )
+        }
+        unless options[:authors].empty?
+          params[:query] = (params[:query] ? params[:query] + ' + (' : '(') +
+                           options[:authors].join(' OR ') + ')'
+        end
+        db.select(params)
       ensure
         db.close
       end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index