lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r505105 - in /lucene/solr/trunk/client/ruby/solrb: lib/solr/connection.rb lib/solr/request.rb lib/solr/response.rb test/conf/solrconfig.xml test/functional/server_test.rb
Date Fri, 09 Feb 2007 00:43:32 GMT
Author: ehatcher
Date: Thu Feb  8 16:43:32 2007
New Revision: 505105

URL: http://svn.apache.org/viewvc?view=rev&rev=505105
Log:
SOLR-147: Add DisMax support

Modified:
    lucene/solr/trunk/client/ruby/solrb/lib/solr/connection.rb
    lucene/solr/trunk/client/ruby/solrb/lib/solr/request.rb
    lucene/solr/trunk/client/ruby/solrb/lib/solr/response.rb
    lucene/solr/trunk/client/ruby/solrb/test/conf/solrconfig.xml
    lucene/solr/trunk/client/ruby/solrb/test/functional/server_test.rb

Modified: lucene/solr/trunk/client/ruby/solrb/lib/solr/connection.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solrb/lib/solr/connection.rb?view=diff&rev=505105&r1=505104&r2=505105
==============================================================================
--- lucene/solr/trunk/client/ruby/solrb/lib/solr/connection.rb (original)
+++ lucene/solr/trunk/client/ruby/solrb/lib/solr/connection.rb Thu Feb  8 16:43:32 2007
@@ -77,11 +77,11 @@
 
   def query(query, options={}, &action)
     # TODO: Shouldn't this return an exception if the Solr status is not ok?  (rather than
true/false).
-    options[:query] = query
-    request = Solr::Request::Standard.new(options)
-    response = send(request)
-    return response unless action
-    response.each {|hit| action.call(hit)}
+    create_and_send_query(Solr::Request::Standard, options.update(:query => query), &action)
+  end
+  
+  def search(query, options={}, &action)
+    create_and_send_query(Solr::Request::Dismax, options.update(:query => query), &action)
   end
 
   # sends a commit message to the server
@@ -149,5 +149,14 @@
     end
   
   end
-
+  
+private
+  
+  def create_and_send_query(klass, options = {}, &action)
+    request = klass.new(options)
+    response = send(request)
+    return response unless action
+    response.each {|hit| action.call(hit)}
+  end
+  
 end

Modified: lucene/solr/trunk/client/ruby/solrb/lib/solr/request.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solrb/lib/solr/request.rb?view=diff&rev=505105&r1=505104&r2=505105
==============================================================================
--- lucene/solr/trunk/client/ruby/solrb/lib/solr/request.rb (original)
+++ lucene/solr/trunk/client/ruby/solrb/lib/solr/request.rb Thu Feb  8 16:43:32 2007
@@ -18,5 +18,6 @@
 require 'solr/request/ping'
 require 'solr/request/select'
 require 'solr/request/standard'
+require 'solr/request/dismax'
 require 'solr/request/update'
 require 'solr/request/index_info'

Modified: lucene/solr/trunk/client/ruby/solrb/lib/solr/response.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solrb/lib/solr/response.rb?view=diff&rev=505105&r1=505104&r2=505105
==============================================================================
--- lucene/solr/trunk/client/ruby/solrb/lib/solr/response.rb (original)
+++ lucene/solr/trunk/client/ruby/solrb/lib/solr/response.rb Thu Feb  8 16:43:32 2007
@@ -17,6 +17,7 @@
 require 'solr/response/ping'
 require 'solr/response/add_document'
 require 'solr/response/standard'
+require 'solr/response/dismax'
 require 'solr/response/commit'
 require 'solr/response/delete'
 require 'solr/response/index_info'

Modified: lucene/solr/trunk/client/ruby/solrb/test/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solrb/test/conf/solrconfig.xml?view=diff&rev=505105&r1=505104&r2=505105
==============================================================================
--- lucene/solr/trunk/client/ruby/solrb/test/conf/solrconfig.xml (original)
+++ lucene/solr/trunk/client/ruby/solrb/test/conf/solrconfig.xml Thu Feb  8 16:43:32 2007
@@ -236,6 +236,30 @@
         -->
      </lst>
   </requestHandler>
+  
+  <!-- DisMaxRequestHandler allows easy searching across multiple fields
+       for simple user-entered phrases. 
+       see http://wiki.apache.org/solr/DisMaxRequestHandler
+   -->
+  <requestHandler name="dismax" class="solr.DisMaxRequestHandler" >
+    <lst name="defaults">
+     <str name="echoParams">explicit</str>
+     <float name="tie">0.01</float>
+     <str name="qf">
+        text^1.9
+     </str>
+     <str name="pf">
+        text^1.9
+     </str>
+     <str name="fl">
+        id, text
+     </str>
+     <str name="mm">
+        2&lt;-1 5&lt;-2 6&lt;90%
+     </str>
+     <int name="ps">100</int> -->
+    </lst>
+  </requestHandler>
 
   <!-- queryResponseWriter plugins... query responses will be written using the
     writer specified by the 'wt' request parameter matching the name of a registered

Modified: lucene/solr/trunk/client/ruby/solrb/test/functional/server_test.rb
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/ruby/solrb/test/functional/server_test.rb?view=diff&rev=505105&r1=505104&r2=505105
==============================================================================
--- lucene/solr/trunk/client/ruby/solrb/test/functional/server_test.rb (original)
+++ lucene/solr/trunk/client/ruby/solrb/test/functional/server_test.rb Thu Feb  8 16:43:32
2007
@@ -41,6 +41,11 @@
     response = @connection.query('Borges')
     assert_equal 1, response.total_hits
     assert_equal '123456', response.hits[0]['id']
+    
+    # look for it via dismax
+    response = @connection.search('Borges')
+    assert_equal 1, response.total_hits
+    assert_equal '123456', response.hits[0]['id']
 
     # delete it
     @connection.delete(123456)



Mime
View raw message