Convert templates to using new QueryResponse response object

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@726780 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2008-12-15 19:41:35 +00:00
parent ebba8adb5c
commit 24cc3d9bce
4 changed files with 70 additions and 69 deletions

View File

@ -1,9 +1,6 @@
#if($params.getBool("debugQuery",false))
<pre>
request = $request
response = $response.values
</pre>
#parse("debug.vm")
#end
<hr/>
Generated by <a href="http://wiki.apache.org/solr/VelocityResponseWriter">VelocityResponseWriter</a>

View File

@ -1,70 +1,67 @@
#set($doclist=$response.values.response)
#set($searcher=$request.searcher)
#set($params=$request.params)
#set($fields=$response.returnFields)
<html>
## TODO: Implement layouts
<head>
<title>#param('title')</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="/solr/admin/jquery-1.2.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="/solr/admin/file?file=/velocity/main.css&contentType=text/css"/>
</head>
<body>
<head>
<title>#param('title')</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="/solr/admin/jquery-1.2.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="/solr/admin/file?file=/velocity/main.css&contentType=text/css"/>
</head>
<body>
<div>
#parse("header.vm")
<div>
#parse("header.vm")
#set($filter_queries = $params.getParams('fq'))
#foreach($fq in $filter_queries)
&gt; <a href="#url_for_filters($filter_queries.subList(0,$velocityCount))">$fq</a>
#end
</div>
#set($filter_queries = $params.getParams('fq'))
#foreach($fq in $filter_queries)
&gt; <a href="#url_for_filters($filter_queries.subList(0,$velocityCount))">$fq</a>
#end
</div>
<div class="query-box">
<form id="query-form" action="/solr/itas" method="GET">
Query: <input type="text" name="q" value="$!params.get('q')"/>
</form>
</div>
<div class="query-box">
<form id="query-form" action="/solr/itas" method="GET">
Query: <input type="text" name="q" value="$!params.get('q')"/>
</form>
</div>
<div class="facet-fields">
#foreach($field in $response.values.facet_counts.facet_fields)
<span class="facet-field">$field.key</span>
<ul>
#foreach($facet in $field.value)
#set($facetURL = "#url_for_nested_facet($field.key, $facet.key)")
#if ($facetURL != '')
<li><a href="$facetURL">$facet.key</a> ($facet.value)</li>
#end
#end
</ul>
#end
</div>
<div class="facet-fields">
#foreach($field in $response.facetFields)
<span class="facet-field">$field.name</span>
<ul>
#foreach($facet in $field.values)
#set($facetURL = "#url_for_nested_facet($field.name, $facet.name)")
#if ($facetURL != '')
<li><a href="$facetURL">$facet.name</a> ($facet.count)</li>
#end
#end
</ul>
#end
</div>
<div class="pagination">
<span><span class="results-found">$page.results_found</span> results found in ${response.responseHeader.QTime} ms</span>
</div>
<div class="pagination">
<span><span class="results-found">$page.results_found</span> results found in ${response.responseHeader.QTime} ms</span>
</div>
<div class="results">
#foreach($id in $doclist.iterator())
#set($doc = $searcher.doc($id,$response.returnFields))
#parse("hit.vm")
#end
</div>
<div class="results">
#foreach($doc in $response.results)
#parse("hit.vm")
#end
</div>
<div class="pagination">
#link_to_previous_page("previous")
<span class="results-found">$page.results_found</span> results found.
Page <span class="page-num">$page.current_page_number</span> of <span
class="page-count">$page.page_count</span>
#link_to_next_page("next")
<div class="pagination">
#link_to_previous_page("previous")
<span class="results-found">$page.results_found</span> results found.
Page <span class="page-num">$page.current_page_number</span> of <span
class="page-count">$page.page_count</span>
#link_to_next_page("next")
<br/>
</div>
<br/>
</div>
<div>
#parse("footer.vm")
</div>
<div>
#parse("footer.vm")
</div>
</body>
</body>
</html>

View File

@ -0,0 +1,9 @@
<h1>REQUEST</h1>
<div>
$esc.html($request)
</div>
<h1>RESPONSE</h1>
<div>
$esc.html($response)
</div>

View File

@ -1,18 +1,16 @@
<div class="result-document">
#foreach($field in $doc.fields)
#if($response.returnFields.contains("*") || $response.returnFields.contains($field.name()))
#foreach($fieldname in $doc.fieldNames)
<p>
<span class="field-name">$field.name() :</span>
<span class="field-name">$fieldname :</span>
<span>
##TODO: Need to provide helpers for field values, including HTML escaping and highlighting
#foreach($value in $doc.getFieldables($field.name()))
$request.schema.getFieldType($field.name()).toExternal($value)
#foreach($value in $doc.getFieldValues($fieldname))
$value
#end
</span>
</p>
#end
#end
#if($params.getBool("debugQuery",false))
<a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle explain</a> <pre style="display:none">$response.values.debug.explain.get($doc.get('id'))</pre>
<a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle explain</a>
<pre style="display:none">$response.getExplainMap().get($doc.getFirstValue('id'))</pre>
#end
</div>