lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r522527 - in /lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare: context.rb controller_extensions.rb
Date Mon, 26 Mar 2007 14:33:09 GMT
Author: ehatcher
Date: Mon Mar 26 07:33:08 2007
New Revision: 522527

URL: http://svn.apache.org/viewvc?view=rev&rev=522527
Log:
Add support for dismax query

Modified:
    lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/context.rb
    lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/controller_extensions.rb

Modified: lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/context.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/context.rb?view=diff&rev=522527&r1=522526&r2=522527
==============================================================================
--- lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/context.rb (original)
+++ lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/context.rb Mon Mar
26 07:33:08 2007
@@ -25,7 +25,7 @@
     @index_info = @connection.send(Solr::Request::IndexInfo.new)
 
     excluded =  @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e|
e.to_s} : []
-    @facet_fields =  @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded
+    @facet_fields =  @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded  #
TODO: is facets_excluded working?  where are the tests?!  :)
 
     @text_fields = @index_info.field_names.find_all {|v| v =~ /_text$/}
     
@@ -63,15 +63,27 @@
 
     qa = applied_facet_queries.collect {|map| q = @facet_queries[map[:name]][:real_query];
map[:negative] ? "-(#{q})" : q}
     qa << build_boolean_query(@queries)
-    request = Solr::Request::Standard.new(:query => qa.join(" AND "),
-                                          :filter_queries => filter_queries(@filters),
-                                          :start => start,
-                                          :rows => max,
-                                          :facets => {
-                                            :fields => @facet_fields, :limit => 20
, :mincount => 1, :sort => :count,
-                                            :queries => facet_queries
-                                          },
-                                          :highlighting => {:field_list => @text_fields})
+    
+    query_type = @solr_config[:solr_query_type] || :dismax
+    query_config = @solr_config["#{query_type.to_s}_query_params".to_sym] || {}
+    solr_params = query_config.merge(:query => qa.join(" AND "),
+                                     :filter_queries => filter_queries(@filters),
+                                     :start => start,
+                                     :rows => max,
+                                     :facets => {
+                                       :fields => @facet_fields, :limit => 20 , :mincount
=> 1, :sort => :count,
+                                       :queries => facet_queries
+                                     },
+                                     :highlighting => {:field_list => @text_fields})
+    if query_type == :dismax
+      solr_params[:phrase_fields] ||= @text_fields
+      if solr_params[:query] == "*:*"
+        solr_params[:query] = ""
+      end
+      request = Solr::Request::Dismax.new(solr_params)  # TODO rename to DisMax
+    else
+      request = Solr::Request::Standard.new(solr_params)
+    end
 
     #TODO: call response.field_facets(??) - maybe field_facets should be return a higher
level? 
 #    logger.info({:query => query, :filter_queries => filters}.inspect)

Modified: lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/controller_extensions.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/controller_extensions.rb?view=diff&rev=522527&r1=522526&r2=522527
==============================================================================
--- lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/controller_extensions.rb
(original)
+++ lucene/solr/trunk/client/ruby/flare/vendor/plugins/flare/lib/flare/controller_extensions.rb
Mon Mar 26 07:33:08 2007
@@ -109,7 +109,7 @@
       end
 
       def clear
-        @flare.clear
+        session[:flare_context] = nil
         redirect_to :action => 'index'
       end
 



Mime
View raw message