SOLR-2383: /browse improvements: generalize range and date facet display

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1095950 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2011-04-22 15:39:07 +00:00
parent b48ad6841f
commit 9db2ff41ae
7 changed files with 54 additions and 22 deletions

View File

@ -134,6 +134,11 @@ New Features
* SOLR-1709: Distributed support for Date and Numeric Range Faceting
(Peter Sturge, David Smiley, hossman)
* SOLR-2383: /browse improvements: generalize range and date facet display
(Jan Høydahl via yonik)
Optimizations
----------------------

View File

@ -774,6 +774,7 @@
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
<str name="mlt.qf">
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
</str>
@ -792,6 +793,8 @@
<int name="facet.range.start">0</int>
<int name="facet.range.end">600</int>
<int name="facet.range.gap">50</int>
<str name="facet.range">popularity</str>
<int name="f.popularity.facet.range.gap">3</int>
<str name="facet.range.other">after</str>
<str name="facet.date">manufacturedate_dt</str>
<str name="facet.date.start">NOW/YEAR-10YEARS</str>

View File

@ -88,13 +88,13 @@
<ul>
#foreach ($facet in $field)
#set($theDate = $date.toDate("yyyy-MM-dd'T'HH:mm:ss'Z'", $facet.key))
#set($value = '["' + $facet.key + '" TO "' + $facet.key + $gap + '"]')
#set($value = '["' + $facet.key + '" TO "' + $facet.key + $gap + '"}')
#set($facetURL = "#url_for_facet_date_filter($fieldName, $value)")
#if ($facetURL != '')
#if ($facet.key != "gap" && $facet.key != "start" && $facet.key != "end" && $facet.key != "before" && $facet.key != "after")
<li><a href="$facetURL">$date.format('MMM yyyy', $theDate)</a> ($facet.value)</li>
<li><a href="$facetURL">$date.format('MMM yyyy', $theDate) $gap</a> ($facet.value)</li>
#end
#if ($facet.key == "before" && $facet.value > 0)
<li><a href="$facetURL">Before</a> ($facet.value)</li>
@ -113,20 +113,20 @@
<span class="facet-field">$display</span>
<ul>
#if($before && $before != "")
#set($value = "[* TO " + $start + "]")
#set($value = "[* TO " + $start + "}")
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
<li><a href="$facetURL">Less than $start</a> ($before)</li>
#end
#foreach ($facet in $field)
#set($rangeEnd = $math.add($facet.key, $gap))
#set($value = "[" + $facet.key + " TO " + $rangeEnd + "]")
#set($value = "[" + $facet.key + " TO " + $rangeEnd + "}")
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
#if ($facetURL != '')
<li><a href="$facetURL">$facet.key</a> ($facet.value)</li>
<li><a href="$facetURL">$facet.key - $rangeEnd</a> ($facet.value)</li>
#end
#end
#if($end && $end != "")
#set($value = "[" + $end + " TO *]")
#if($end && $end != "" && $after > 0)
#set($value = "[" + $end + " TO *}")
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
<li><a href="$facetURL">More than $math.toNumber($end)</a> ($after)</li>
#end
@ -180,4 +180,8 @@
$v
#end
#end
#end
#end
#macro(capitalize $name)
${name.substring(0,1).toUpperCase()}${name.substring(1)}
#end

View File

@ -1,5 +1,9 @@
##TODO: Generically deal with all dates
<h2 #annTitle("Facets generated by adding &facet.date= to the request")>Date Facets</h2>
#set($field = $response.response.facet_counts.facet_dates.manufacturedate_dt)
#set($gap = $response.response.facet_counts.facet_dates.manufacturedate_dt.gap)
#display_facet_date($field, "Manufacture Date", "manufacturedate_dt", $gap)
#foreach ($field in $response.response.facet_counts.facet_dates)
#set($name = $field.key)
#set($display = "#capitalize($name)")
#set($f = $field.value)
#set($gap = $field.value.gap)
#display_facet_date($f, $display, $name, $gap)
#end

View File

@ -1,10 +1,12 @@
<h2 #annTitle("Facets generated by adding &facet.range= to the request")>Range Facets</h2>
#set($field = $response.response.facet_counts.facet_ranges.price.counts)
#set($start = $response.response.facet_counts.facet_ranges.price.start)
#set($end = $response.response.facet_counts.facet_ranges.price.end)
#set($gap = $response.response.facet_counts.facet_ranges.price.gap)
#set($before = $response.response.facet_counts.facet_ranges.price.before)
#set($after = $response.response.facet_counts.facet_ranges.price.after)
##TODO: Make this display the "range", not just the lower value
##TODO: Have a generic way to deal with ranges
#display_facet_range($field, "Price (in $)", "price", $start, $end, $gap, $before, $after)
#foreach ($field in $response.response.facet_counts.facet_ranges)
#set($name = $field.key)
#set($display = "#capitalize($name)")
#set($f = $field.value.counts)
#set($start = $field.value.start)
#set($end = $field.value.end)
#set($gap = $field.value.gap)
#set($before = $field.value.before)
#set($after = $field.value.after)
#display_facet_range($f, $display, $name, $start, $end, $gap, $before, $after)
#end

View File

@ -18,6 +18,18 @@
margin-left: 20px;
}
.parsed_query_header {
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;
font-weight: bold;
}
.parsed_query {
font-family: Courier, Courier New, monospaced;
font-size: 10pt;
font-weight: normal;
}
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 10pt;

View File

@ -27,14 +27,16 @@
#end
#end
</div>
<div class="parsed_query_header">
#if($request.params.get('debugQuery'))
<a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle parsed query</a>
<pre style="display:none">$response.response.debug.parsedquery</pre>
<a href="#" onclick='jQuery(this).siblings("div").toggle(); return false;'>toggle parsed query</a>
<div class="parsed_query" style="display:none">$response.response.debug.parsedquery</div>
#end
#set($queryOpts = $request.params.get("queryOpts"))
#if($queryOpts && $queryOpts != "")
<input type="hidden" name="queryOpts" value="$queryOpts"/>
#end
</div>
</form>
</div>