From f4e41c8c8f7f8e14ed22007063d84524d83df710 Mon Sep 17 00:00:00 2001 From: Koji Sekiguchi Date: Sat, 17 May 2008 03:31:18 +0000 Subject: [PATCH] SOLR-537: Use of hl.maxAlternateFieldLength parameter from solr-ruby git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@657290 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 6 ++++++ client/ruby/solr-ruby/lib/solr/request/standard.rb | 5 +++++ client/ruby/solr-ruby/test/unit/standard_request_test.rb | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index ca515800023..42d665ff891 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -251,6 +251,12 @@ New Features (Walter Ferrara via hossman) 46. SOLR-557: Added SolrCore.getSearchComponents() to return an unmodifiable Map. (gsingers) + +47. SOLR-516: Added hl.maxAlternateFieldLength parameter, to set max length for hl.alternateField + (Koji Sekiguchi via klaas) + +48. SOLR-537: Use of hl.maxAlternateFieldLength parameter from solr-ruby + (koji) Changes in runtime behavior 1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. This diff --git a/client/ruby/solr-ruby/lib/solr/request/standard.rb b/client/ruby/solr-ruby/lib/solr/request/standard.rb index 720c24c6a0b..0209d70cdb7 100755 --- a/client/ruby/solr-ruby/lib/solr/request/standard.rb +++ b/client/ruby/solr-ruby/lib/solr/request/standard.rb @@ -106,6 +106,11 @@ class Solr::Request::Standard < Solr::Request::Select hash["f.#{k}.hl.alternateField"] = v end end + if @params[:highlighting][:max_alternate_field_length] + @params[:highlighting][:max_alternate_field_length].each do |k,v| + hash["f.#{k}.hl.maxAlternateFieldLength"] = v + end + end end if @params[:mlt] diff --git a/client/ruby/solr-ruby/test/unit/standard_request_test.rb b/client/ruby/solr-ruby/test/unit/standard_request_test.rb index 3f0d1419ca8..117e5100956 100755 --- a/client/ruby/solr-ruby/test/unit/standard_request_test.rb +++ b/client/ruby/solr-ruby/test/unit/standard_request_test.rb @@ -103,6 +103,8 @@ class StandardRequestTest < Test::Unit::TestCase request = Solr::Request::Standard.new(:query => 'query', :highlighting => { :field_list => ['title', 'author'], + :alternate_fields => {'title'=>'title', 'author'=>'author'}, + :max_alternate_field_length => {'title'=>30, 'author'=>20}, :max_snippets => 3, :require_field_match => true, :prefix => "", @@ -114,6 +116,10 @@ class StandardRequestTest < Test::Unit::TestCase hash = request.to_hash assert_equal true, hash[:hl] assert_equal "title,author", hash["hl.fl"] + assert_equal "title", hash["f.title.hl.alternateField"] + assert_equal "author", hash["f.author.hl.alternateField"] + assert_equal 30, hash["f.title.hl.maxAlternateFieldLength"] + assert_equal 20, hash["f.author.hl.maxAlternateFieldLength"] assert_equal true, hash["hl.requireFieldMatch"] assert_equal "", hash["hl.simple.pre"] assert_equal "", hash["hl.simple.post"]