diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 84e728b46da..20237e40a96 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
----------------------
diff --git a/solr/example/solr/conf/solrconfig.xml b/solr/example/solr/conf/solrconfig.xml
index 213db0af94b..0d72cb2d183 100755
--- a/solr/example/solr/conf/solrconfig.xml
+++ b/solr/example/solr/conf/solrconfig.xml
@@ -774,6 +774,7 @@
*:*
10
*,score
+
text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4
@@ -792,6 +793,8 @@
0
600
50
+ popularity
+ 3
after
manufacturedate_dt
NOW/YEAR-10YEARS
diff --git a/solr/example/solr/conf/velocity/VM_global_library.vm b/solr/example/solr/conf/velocity/VM_global_library.vm
index 9ec7e09a151..3d33b512055 100644
--- a/solr/example/solr/conf/velocity/VM_global_library.vm
+++ b/solr/example/solr/conf/velocity/VM_global_library.vm
@@ -88,13 +88,13 @@
#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")
- - $date.format('MMM yyyy', $theDate) ($facet.value)
+ - $date.format('MMM yyyy', $theDate) $gap ($facet.value)
#end
#if ($facet.key == "before" && $facet.value > 0)
- Before ($facet.value)
@@ -113,20 +113,20 @@
$display
#if($before && $before != "")
- #set($value = "[* TO " + $start + "]")
+ #set($value = "[* TO " + $start + "}")
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
- Less than $start ($before)
#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 != '')
- - $facet.key ($facet.value)
+ - $facet.key - $rangeEnd ($facet.value)
#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)")
- More than $math.toNumber($end) ($after)
#end
@@ -180,4 +180,8 @@
$v
#end
#end
-#end
\ No newline at end of file
+#end
+
+#macro(capitalize $name)
+ ${name.substring(0,1).toUpperCase()}${name.substring(1)}
+#end
\ No newline at end of file
diff --git a/solr/example/solr/conf/velocity/facet_dates.vm b/solr/example/solr/conf/velocity/facet_dates.vm
index 5fd2151256c..5835212a1bb 100644
--- a/solr/example/solr/conf/velocity/facet_dates.vm
+++ b/solr/example/solr/conf/velocity/facet_dates.vm
@@ -1,5 +1,9 @@
##TODO: Generically deal with all dates
Date Facets
-#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
\ No newline at end of file
diff --git a/solr/example/solr/conf/velocity/facet_ranges.vm b/solr/example/solr/conf/velocity/facet_ranges.vm
index a5e9b56e573..66804019590 100644
--- a/solr/example/solr/conf/velocity/facet_ranges.vm
+++ b/solr/example/solr/conf/velocity/facet_ranges.vm
@@ -1,10 +1,12 @@
Range Facets
-#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
\ No newline at end of file
diff --git a/solr/example/solr/conf/velocity/main.css b/solr/example/solr/conf/velocity/main.css
index 076745d73bc..ed5687e392c 100644
--- a/solr/example/solr/conf/velocity/main.css
+++ b/solr/example/solr/conf/velocity/main.css
@@ -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;
diff --git a/solr/example/solr/conf/velocity/query.vm b/solr/example/solr/conf/velocity/query.vm
index d9cc32c8311..ddbab3fcf73 100644
--- a/solr/example/solr/conf/velocity/query.vm
+++ b/solr/example/solr/conf/velocity/query.vm
@@ -27,14 +27,16 @@
#end
#end
+