<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title><%= display_title(@query) %></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link media="screen" href="/stylesheets/style.css" type="text/css" rel="stylesheet" />
</head>
<body onload="document.f1.query.focus();">
<div id="wrap">
<div id="header">
  <h1><a href="#">Solr検索サンプル</a></h1>
  <br/>
  <% form_tag({},:method=>:get,:name=>'f1') do %>
    <%=text_field_tag :query,display_query_text(@query) %>
    <%=submit_tag '検索' %>
  <% end %>
</div>

<%
   rp = @response['responseHeader']['params']
   start = ( rp['start'] || 0 ).to_i
   rows = ( rp['rows'] || 10 ).to_i
   found = ( @response['response']['numFound'] || 0 ).to_i
   qtime = sprintf( "%.3f", ( @response['responseHeader']['QTime'] || 0 ).to_f / 1000 )
%>

<%= render :partial => 'result_header', :locals => {:rp=>rp,:start=>start,:rows=>rows,:found=>found,:qtime=>qtime,:query=>@query} %>

<div id="content">

<% if found == 0 then %>
<b><%= display_query_text(@query) %></b> は見つかりませんでした。他の検索語で試してください。
<% else %><!-- if something found -->

  <div id="result" class="right">

  <% @response['response']['docs'].each do |doc| %>
    <%= render :partial => 'document', :locals => {:doc=>doc, :hl=>@response['highlighting']} %>
  <% end %>

  </div><!-- end of #result -->

  <div id="facet" class="left">

  <% @response['facet_counts']['facet_fields'].each do |field,facet_pairs| %>
    <%= render :partial => 'facet_field', :locals => {:field=>field, :facet_pairs=>facet_pairs, :query=>@query, :filters=>@filters} %>
  <% end %>

  <% @facet_queries.each do |field,args| %>
    <%= render :partial => 'facet_queries', :locals => {:field=>field, :args=>args, :facet_queries=>@response['facet_counts']['facet_queries'], :query=>@query, :filters=>@filters} %>
  <% end %>

  </div><!-- end of #facet -->

<% end %><!-- end of if something found -->

<div style="CLEAR: both"></div>

</div><!-- end of #content -->

<%= render :partial => 'pagination', :locals => {:start=>start,:rows=>rows,:found=>found, :query=>@query, :filters=>@filters} %>

<div id="footer">著作権表示など</div></div></body>
</html>
