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
This commit is contained in:
Koji Sekiguchi 2008-05-17 03:31:18 +00:00
parent bc905bb00d
commit f4e41c8c8f
3 changed files with 17 additions and 0 deletions

View File

@ -251,6 +251,12 @@ New Features
(Walter Ferrara via hossman) (Walter Ferrara via hossman)
46. SOLR-557: Added SolrCore.getSearchComponents() to return an unmodifiable Map. (gsingers) 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 Changes in runtime behavior
1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. This 1. SOLR-559: use Lucene updateDocument, deleteDocuments methods. This

View File

@ -106,6 +106,11 @@ class Solr::Request::Standard < Solr::Request::Select
hash["f.#{k}.hl.alternateField"] = v hash["f.#{k}.hl.alternateField"] = v
end end
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 end
if @params[:mlt] if @params[:mlt]

View File

@ -103,6 +103,8 @@ class StandardRequestTest < Test::Unit::TestCase
request = Solr::Request::Standard.new(:query => 'query', request = Solr::Request::Standard.new(:query => 'query',
:highlighting => { :highlighting => {
:field_list => ['title', 'author'], :field_list => ['title', 'author'],
:alternate_fields => {'title'=>'title', 'author'=>'author'},
:max_alternate_field_length => {'title'=>30, 'author'=>20},
:max_snippets => 3, :max_snippets => 3,
:require_field_match => true, :require_field_match => true,
:prefix => "<blink>", :prefix => "<blink>",
@ -114,6 +116,10 @@ class StandardRequestTest < Test::Unit::TestCase
hash = request.to_hash hash = request.to_hash
assert_equal true, hash[:hl] assert_equal true, hash[:hl]
assert_equal "title,author", hash["hl.fl"] 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 true, hash["hl.requireFieldMatch"]
assert_equal "<blink>", hash["hl.simple.pre"] assert_equal "<blink>", hash["hl.simple.pre"]
assert_equal "</blink>", hash["hl.simple.post"] assert_equal "</blink>", hash["hl.simple.post"]