mirror of https://github.com/apache/lucene.git
Add highlighter fragment size and more like this support to Standard request
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@568347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dfa0b8a004
commit
7068f0344e
|
@ -13,7 +13,7 @@
|
|||
class Solr::Request::Standard < Solr::Request::Select
|
||||
|
||||
VALID_PARAMS = [:query, :sort, :default_field, :operator, :start, :rows,
|
||||
:filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting]
|
||||
:filter_queries, :field_list, :debug_query, :explain_other, :facets, :highlighting, :mlt]
|
||||
|
||||
def initialize(params)
|
||||
super('standard')
|
||||
|
@ -98,8 +98,21 @@ class Solr::Request::Standard < Solr::Request::Select
|
|||
hash["hl.requireFieldMatch"] = @params[:highlighting][:require_field_match]
|
||||
hash["hl.simple.pre"] = @params[:highlighting][:prefix]
|
||||
hash["hl.simple.post"] = @params[:highlighting][:suffix]
|
||||
hash["hl.fragsize"] = @params[:highlighting][:fragment_size]
|
||||
end
|
||||
|
||||
if @params[:mlt]
|
||||
hash[:mlt] = true
|
||||
hash["mlt.count"] = @params[:mlt][:count]
|
||||
hash["mlt.fl"] = @params[:mlt][:field_list]
|
||||
hash["mlt.mintf"] = @params[:mlt][:min_term_freq]
|
||||
hash["mlt.mindf"] = @params[:mlt][:min_doc_freq]
|
||||
hash["mlt.minwl"] = @params[:mlt][:min_word_length]
|
||||
hash["mlt.maxwl"] = @params[:mlt][:max_word_length]
|
||||
hash["mlt.maxqt"] = @params[:mlt][:max_query_terms]
|
||||
hash["mlt.maxntp"] = @params[:mlt][:max_tokens_parsed]
|
||||
hash["mlt.boost"] = @params[:mlt][:boost]
|
||||
end
|
||||
|
||||
hash.merge(super.to_hash)
|
||||
end
|
||||
|
|
|
@ -104,7 +104,8 @@ class StandardRequestTest < Test::Unit::TestCase
|
|||
:max_snippets => 3,
|
||||
:require_field_match => true,
|
||||
:prefix => "<blink>",
|
||||
:suffix => "</blink>"
|
||||
:suffix => "</blink>",
|
||||
:fragment_size => 300
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -114,6 +115,31 @@ class StandardRequestTest < Test::Unit::TestCase
|
|||
assert_equal true, hash["hl.requireFieldMatch"]
|
||||
assert_equal "<blink>", hash["hl.simple.pre"]
|
||||
assert_equal "</blink>", hash["hl.simple.post"]
|
||||
assert_equal 300, hash["hl.fragsize"]
|
||||
end
|
||||
|
||||
def test_mlt
|
||||
request = Solr::Request::Standard.new(:query => 'query',
|
||||
:mlt => {
|
||||
:count => 5, :field_list => ['field1', 'field2'],
|
||||
:min_term_freq => 3, :min_doc_freq => 10,
|
||||
:min_word_length => 4, :max_word_length => 17,
|
||||
:max_query_terms => 20, :max_tokens_parsed => 100,
|
||||
:boost => true
|
||||
}
|
||||
)
|
||||
|
||||
hash = request.to_hash
|
||||
assert_equal true, hash[:mlt]
|
||||
assert_equal 5, hash["mlt.count"]
|
||||
assert_equal ['field1', 'field2'], hash["mlt.fl"]
|
||||
assert_equal 3, hash["mlt.mintf"]
|
||||
assert_equal 10, hash["mlt.mindf"]
|
||||
assert_equal 4, hash["mlt.minwl"]
|
||||
assert_equal 17, hash["mlt.maxwl"]
|
||||
assert_equal 20, hash["mlt.maxqt"]
|
||||
assert_equal 100, hash["mlt.maxntp"]
|
||||
assert_equal true, hash["mlt.boost"]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue