mirror of https://github.com/apache/lucene.git
Fix issue where only facet.query was being requested but no fields
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@537760 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ca0dedf563
commit
9f596e279c
|
@ -71,18 +71,20 @@ class Solr::Request::Standard < Solr::Request::Select
|
||||||
hash["facet.missing"] = @params[:facets][:missing]
|
hash["facet.missing"] = @params[:facets][:missing]
|
||||||
hash["facet.mincount"] = @params[:facets][:mincount]
|
hash["facet.mincount"] = @params[:facets][:mincount]
|
||||||
hash["facet.prefix"] = @params[:facets][:prefix]
|
hash["facet.prefix"] = @params[:facets][:prefix]
|
||||||
@params[:facets][:fields].each do |f|
|
if @params[:facets][:fields] # facet fields are optional (could be facet.query only)
|
||||||
if f.kind_of? Hash
|
@params[:facets][:fields].each do |f|
|
||||||
key = f.keys[0]
|
if f.kind_of? Hash
|
||||||
value = f[key]
|
key = f.keys[0]
|
||||||
hash["facet.field"] << key
|
value = f[key]
|
||||||
hash["f.#{key}.facet.sort"] = (value[:sort] == :count) if value[:sort]
|
hash["facet.field"] << key
|
||||||
hash["f.#{key}.facet.limit"] = value[:limit]
|
hash["f.#{key}.facet.sort"] = (value[:sort] == :count) if value[:sort]
|
||||||
hash["f.#{key}.facet.missing"] = value[:missing]
|
hash["f.#{key}.facet.limit"] = value[:limit]
|
||||||
hash["f.#{key}.facet.mincount"] = value[:mincount]
|
hash["f.#{key}.facet.missing"] = value[:missing]
|
||||||
hash["f.#{key}.facet.prefix"] = value[:prefix]
|
hash["f.#{key}.facet.mincount"] = value[:mincount]
|
||||||
else
|
hash["f.#{key}.facet.prefix"] = value[:prefix]
|
||||||
hash["facet.field"] << f
|
else
|
||||||
|
hash["facet.field"] << f
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,6 +55,17 @@ class StandardRequestTest < Test::Unit::TestCase
|
||||||
assert_match /debugQuery/, request.to_s
|
assert_match /debugQuery/, request.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_only_facet_query
|
||||||
|
request = Solr::Request::Standard.new(:query => 'query',
|
||||||
|
:facets => {
|
||||||
|
:queries => ["q1", "q2"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
hash = request.to_hash
|
||||||
|
assert_equal ["q1", "q2"], hash["facet.query"]
|
||||||
|
end
|
||||||
|
|
||||||
def test_facet_params_all
|
def test_facet_params_all
|
||||||
request = Solr::Request::Standard.new(:query => 'query',
|
request = Solr::Request::Standard.new(:query => 'query',
|
||||||
:facets => {
|
:facets => {
|
||||||
|
|
Loading…
Reference in New Issue