component rendering is much slower than partial rendering, and nothing custom was being done in DocumentController (yet) so switch to partial rendering for now

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@512206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-02-27 10:19:24 +00:00
parent 919a3881d0
commit bb81d5f485
6 changed files with 36 additions and 8 deletions

View File

@ -30,7 +30,10 @@ class BrowseController < ApplicationController
:filter_queries => filters,
:rows => @results_per_page,
:start => @start,
:facets => {:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count, :debug_query=>true},
:facets => {
:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count,
# :queries => session[:saved].collect {|constraints| make_query(constraints)}
},
:highlighting => {:field_list => @text_fields})
logger.info({:query => query, :filter_queries => filters}.inspect)
@response = solr(request)
@ -104,6 +107,12 @@ class BrowseController < ApplicationController
redirect_to :action => 'index'
end
def save
session[:saved] ||= {}
session[:saved][params[:name]] = {:filters => session[:filters], :queries => session[:queries]}
redirect_to :action => 'index'
end
private
def flare_before
session[:queries] ||= []
@ -125,4 +134,23 @@ class BrowseController < ApplicationController
results.field_facets(field)
end
def make_query(constraints)
queries = constraints[:queries]
if queries.nil? || queries.empty?
query = "*:*"
else
query = session[:queries].collect{|q| "#{q[:negative] ? '-' : ''}(#{q[:query]})"}.join(' AND ')
end
filter = constraints[:filters].collect do |filter|
value = filter[:value]
if value != "[* TO *]"
value = "\"#{value}\""
end
"#{filter[:negative] ? '-' : ''}#{filter[:field]}:#{value}"
end.join(" AND ")
"#{query} AND #{filter}"
end
end

View File

@ -64,7 +64,7 @@
<div id="results"><table cellpadding="10">
<% @response.each do |doc| %>
<%= render_component :controller => DocumentController, :action => "result", :params => {:doc => doc, :response => @response} %>
<%= render :partial => "document/document_#{SOLR_ENV}", :locals => {:doc => doc, :response => @response}%>
<% end %>
</table>
</div>

View File

@ -2,9 +2,9 @@
<td>
<table class="entry">
<tr>
<td class="title" colspan="2"><%=@doc['title_text']%></td>
<td class="title" colspan="2"><%=doc['title_text']%></td>
</tr>
<% @doc.each do |k,v|; highlighting = @response.highlighted(@doc['id'], k) %>
<% doc.each do |k,v|; highlighting = response.highlighted(doc['id'], k) %>
<tr><td class="field"><%=k%>:</td><td><%= highlighting ? "...#{highlighting}..." : (v.respond_to?('join') ? v.join(',') : v.to_s)%></td></tr>
<% end %>
</table>

View File

@ -1,8 +1,8 @@
<%
virgo_link = "http://virgo.lib.virginia.edu/uhtbin/cgisirsi/uva/0/0/5?searchdata1=#{@doc['id'][1..-1]}%7bCKEY%7d"
virgo_link = "http://virgo.lib.virginia.edu/uhtbin/cgisirsi/uva/0/0/5?searchdata1=#{doc['id'][1..-1]}%7bCKEY%7d"
# url = URI.parse(virgo_link)
# res = Net::HTTP.start(url.host, url.port) {|http|
# http.get("/uhtbin/cgisirsi/uva/0/0/5?searchdata1=#{@doc['id'][1..-1]}{CKEY}")
# http.get("/uhtbin/cgisirsi/uva/0/0/5?searchdata1=#{doc['id'][1..-1]}{CKEY}")
# }
# availability = Regexp.new("Copy\ info\:(.*)td\>", Regexp::MULTILINE).match(res.body)[1]
%>
@ -10,9 +10,9 @@
<td>
<table class="entry">
<tr>
<td class="title" colspan="2"><%= link_to @doc['title_text'], virgo_link, {:target => "_blank"}%></td>
<td class="title" colspan="2"><%= link_to doc['title_text'], virgo_link, {:target => "_blank"}%></td>
</tr>
<% @doc.each do |k,v|; highlighting = @response.highlighted(@doc['id'], k) %>
<% doc.each do |k,v|; highlighting = response.highlighted(doc['id'], k) %>
<tr><td class="field"><%=k%>:</td><td><%= highlighting ? "...#{highlighting}..." : (v.respond_to?('join') ? v.join(',') : v.to_s)%></td></tr>
<% end %>
<tr>