mirror of https://github.com/apache/lucene.git
SOLR-2741 Bugs in facet range display in trunk
Also removes promotion of deprecated facet.date from example git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1165648 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f90632562
commit
bf9cde01f1
|
@ -62,7 +62,7 @@ Detailed Change List
|
|||
|
||||
New Features
|
||||
----------------------
|
||||
|
||||
|
||||
* SOLR-571: The autowarmCount for LRUCaches (LRUCache and FastLRUCache) now
|
||||
supports "percentages" which get evaluated relative the current size of
|
||||
the cache when warming happens.
|
||||
|
@ -200,6 +200,8 @@ Optimizations
|
|||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
* SOLR-2741: Bugs in facet range display in trunk (janhoy)
|
||||
|
||||
* SOLR-1908: Fixed SignatureUpdateProcessor to fail to initialize on
|
||||
invalid config. Specifically: a signatureField that does not exist,
|
||||
or overwriteDupes=true with a signatureField that is not indexed.
|
||||
|
|
|
@ -815,20 +815,21 @@
|
|||
<str name="facet.query">GB</str>
|
||||
<str name="facet.mincount">1</str>
|
||||
<str name="facet.pivot">cat,inStock</str>
|
||||
<str name="facet.range">price</str>
|
||||
<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>
|
||||
<str name="facet.date.end">NOW</str>
|
||||
<str name="facet.mincount">1</str>
|
||||
<str name="facet.date.gap">+1YEAR</str>
|
||||
<str name="facet.date.other">before</str>
|
||||
<str name="facet.date.other">after</str>
|
||||
<str name="facet.range">price</str>
|
||||
<int name="f.price.facet.range.start">0</int>
|
||||
<int name="f.price.facet.range.end">600</int>
|
||||
<int name="f.price.facet.range.gap">50</int>
|
||||
<str name="facet.range">popularity</str>
|
||||
<int name="f.popularity.facet.range.start">0</int>
|
||||
<int name="f.popularity.facet.range.end">10</int>
|
||||
<int name="f.popularity.facet.range.gap">3</int>
|
||||
<str name="facet.range">manufacturedate_dt</str>
|
||||
<str name="f.manufacturedate_dt.facet.range.start">NOW/YEAR-10YEARS</str>
|
||||
<str name="f.manufacturedate_dt.facet.range.end">NOW</str>
|
||||
<str name="f.manufacturedate_dt.facet.range.gap">+1YEAR</str>
|
||||
<str name="f.manufacturedate_dt.facet.range.other">before</str>
|
||||
<str name="f.manufacturedate_dt.facet.range.other">after</str>
|
||||
|
||||
<!-- Highlighting defaults -->
|
||||
<str name="hl">on</str>
|
||||
|
|
|
@ -83,76 +83,31 @@
|
|||
#end
|
||||
#end
|
||||
|
||||
#macro(display_facet_date $field, $display, $fieldName, $gap)
|
||||
<span class="facet-field">$display</span>
|
||||
<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($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) $gap</a> ($facet.value)</li>
|
||||
#end
|
||||
#if ($facet.key == "before" && $facet.value > 0)
|
||||
<li><a href="$facetURL">Before</a> ($facet.value)</li>
|
||||
#end
|
||||
#if ($facet.key == "after" && $facet.value > 0)
|
||||
<li><a href="$facetURL">After</a> ($facet.value)</li>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</ul>
|
||||
#end
|
||||
|
||||
|
||||
|
||||
#macro(display_facet_range $field, $display, $fieldName, $start, $end, $gap, $before, $after)
|
||||
<span class="facet-field">$display</span>
|
||||
<ul>
|
||||
#if($before && $before != "")
|
||||
#set($value = "[* TO " + $start + "}")
|
||||
#set($value = "[* TO " + "#format_value($start)" + "}")
|
||||
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
|
||||
<li><a href="$facetURL">Less than $start</a> ($before)</li>
|
||||
<li><a href="$facetURL">Less than #format_value($start)</a> ($before)</li>
|
||||
#end
|
||||
#foreach ($facet in $field)
|
||||
#set($rangeEnd = $math.add($facet.key, $gap))
|
||||
#set($rangeEnd = "#range_get_to_value($facet.key, $gap)")
|
||||
#set($value = "[" + $facet.key + " TO " + $rangeEnd + "}")
|
||||
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
|
||||
#if ($facetURL != '')
|
||||
<li><a href="$facetURL">$facet.key - $rangeEnd</a> ($facet.value)</li>
|
||||
<li><a href="$facetURL">$facet.key - #format_value($rangeEnd)</a> ($facet.value)</li>
|
||||
#end
|
||||
#end
|
||||
#if($end && $end != "" && $after > 0)
|
||||
#set($value = "[" + $end + " TO *}")
|
||||
#set($value = "[" + "#format_value($end)" + " TO *}")
|
||||
#set($facetURL = "#url_for_facet_range_filter($fieldName, $value)")
|
||||
<li><a href="$facetURL">More than $math.toNumber($end)</a> ($after)</li>
|
||||
<li><a href="$facetURL">More than #format_value($end)</a> ($after)</li>
|
||||
#end
|
||||
</ul>
|
||||
#end
|
||||
|
||||
## <lst name="facet_pivot">
|
||||
## <arr name="cat,inStock">
|
||||
## <lst>
|
||||
## <str name="field">cat</str>
|
||||
## <str name="value">electronics</str>
|
||||
## <int name="count">17</int>
|
||||
## <arr name="pivot">
|
||||
## <lst>
|
||||
## <str name="field">inStock</str>
|
||||
## <str name="value">true</str>
|
||||
## <int name="count">13</int>
|
||||
## </lst>
|
||||
## <lst>
|
||||
## <str name="field">inStock</str>
|
||||
## <str name="value">false</str>
|
||||
## <int name="count">4</int>
|
||||
## </lst>
|
||||
## </arr>
|
||||
## </lst>
|
||||
|
||||
## $pivots is a list of facet_pivot
|
||||
#macro(display_facet_pivot $pivots, $display)
|
||||
#if($pivots.size() > 0)
|
||||
|
@ -182,6 +137,24 @@
|
|||
#end
|
||||
#end
|
||||
|
||||
#macro(capitalize $name)
|
||||
${name.substring(0,1).toUpperCase()}${name.substring(1)}
|
||||
#macro(utc_date $theDate)
|
||||
$date.format("yyyy-MM-dd'T'HH:mm:ss'Z'",$theDate,$date.getLocale(),$date.getTimeZone().getTimeZone("UTC"))##
|
||||
#end
|
||||
|
||||
#macro(format_value $val)
|
||||
#if(${val.class.name} == "java.util.Date")
|
||||
#utc_date($val)##
|
||||
#else
|
||||
$val##
|
||||
#end
|
||||
#end
|
||||
|
||||
#macro(range_get_to_value $inval, $gapval)
|
||||
#if(${gapval.class.name} == "java.lang.String")
|
||||
$inval$gapval##
|
||||
#elseif(${gapval.class.name} == "java.lang.Float" || ${inval.class.name} == "java.lang.Float")
|
||||
$math.toDouble($math.add($inval,$gapval))##
|
||||
#else
|
||||
$math.add($inval,$gapval)##
|
||||
#end
|
||||
#end
|
|
@ -1,9 +0,0 @@
|
|||
##TODO: Generically deal with all dates
|
||||
<h2 #annTitle("Facets generated by adding &facet.date= to the request")>Date Facets</h2>
|
||||
#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
|
|
@ -1,7 +1,7 @@
|
|||
<h2 #annTitle("Facets generated by adding &facet.range= to the request")>Range Facets</h2>
|
||||
#foreach ($field in $response.response.facet_counts.facet_ranges)
|
||||
#set($name = $field.key)
|
||||
#set($display = "#capitalize($name)")
|
||||
#set($display = $name)
|
||||
#set($f = $field.value.counts)
|
||||
#set($start = $field.value.start)
|
||||
#set($end = $field.value.end)
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
#parse('facet_fields.vm')
|
||||
#parse('facet_fields.vm')
|
||||
#parse('facet_queries.vm')
|
||||
#parse('facet_ranges.vm')
|
||||
#parse('facet_dates.vm')
|
||||
#parse('facet_pivot.vm')
|
||||
#parse('cluster.vm')
|
||||
|
||||
|
||||
|
||||
#parse('cluster.vm')
|
Loading…
Reference in New Issue