mirror of https://github.com/apache/lucene.git
SOLR-1240: facet.range.include now defaults to 'lower' (facet.date.include still defaults to lower,upper,edge)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1075603 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70c8bff01f
commit
21355a452b
|
@ -180,12 +180,13 @@ public interface FacetParams {
|
|||
* exclusive of their end points.
|
||||
* </p>
|
||||
* <p>
|
||||
* The default value if none are specified is: [lower,upper,edge]
|
||||
* The default value if none are specified is: [lower,upper,edge] <i>(NOTE: This is different then FACET_RANGE_INCLUDE)</i>
|
||||
* </p>
|
||||
* <p>
|
||||
* Can be overriden on a per field basis.
|
||||
* </p>
|
||||
* @see FacetRangeInclude
|
||||
* @see #FACET_RANGE_INCLUDE
|
||||
*/
|
||||
public static final String FACET_DATE_INCLUDE = FACET_DATE + ".include";
|
||||
|
||||
|
@ -230,13 +231,6 @@ public interface FacetParams {
|
|||
* Can be overriden on a per field basis.
|
||||
*/
|
||||
public static final String FACET_RANGE_OTHER = FACET_RANGE + ".other";
|
||||
/**
|
||||
* String indicating whether ranges for numerical range faceting
|
||||
* should be exclusive or inclusive. By default both the start and
|
||||
* end point are inclusive.
|
||||
* Can be overriden on a per field basis.
|
||||
* @see FacetNumberExclusive
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -245,7 +239,7 @@ public interface FacetParams {
|
|||
* exclusive of their end points.
|
||||
* </p>
|
||||
* <p>
|
||||
* The default value if none are specified is: [lower,upper,edge]
|
||||
* The default value if none are specified is: lower
|
||||
* </p>
|
||||
* <p>
|
||||
* Can be overriden on a per field basis.
|
||||
|
@ -335,15 +329,16 @@ public interface FacetParams {
|
|||
}
|
||||
/**
|
||||
* Convinience method for parsing the param value according to the
|
||||
* correct semantics.
|
||||
* correct semantics and applying the default of "LOWER"
|
||||
*/
|
||||
public static EnumSet<FacetRangeInclude> parseParam(final String[] param) {
|
||||
// short circut for default behavior
|
||||
if (null == param || 0 == param.length )
|
||||
return EnumSet.of(LOWER, UPPER, EDGE);
|
||||
return EnumSet.of(LOWER);
|
||||
|
||||
// build up set containing whatever is specified
|
||||
final EnumSet<FacetRangeInclude> include = EnumSet.noneOf(FacetRangeInclude.class);
|
||||
final EnumSet<FacetRangeInclude> include
|
||||
= EnumSet.noneOf(FacetRangeInclude.class);
|
||||
for (final String o : param) {
|
||||
include.add(FacetRangeInclude.get(o));
|
||||
}
|
||||
|
|
|
@ -857,8 +857,16 @@ public class SimpleFacets {
|
|||
|
||||
final int minCount = params.getFieldInt(f,FacetParams.FACET_MINCOUNT, 0);
|
||||
|
||||
final EnumSet<FacetRangeInclude> include = FacetRangeInclude.parseParam
|
||||
(params.getFieldParams(f,FacetParams.FACET_DATE_INCLUDE));
|
||||
String[] iStrs = params.getFieldParams(f,FacetParams.FACET_DATE_INCLUDE);
|
||||
// Legacy support for default of [lower,upper,edge] for date faceting
|
||||
// this is not handled by FacetRangeInclude.parseParam because
|
||||
// range faceting has differnet defaults
|
||||
final EnumSet<FacetRangeInclude> include =
|
||||
(null == iStrs || 0 == iStrs.length ) ?
|
||||
EnumSet.of(FacetRangeInclude.LOWER,
|
||||
FacetRangeInclude.UPPER,
|
||||
FacetRangeInclude.EDGE)
|
||||
: FacetRangeInclude.parseParam(iStrs);
|
||||
|
||||
try {
|
||||
Date low = start;
|
||||
|
|
|
@ -370,6 +370,12 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
final String pre = "//lst[@name='"+b+"']/lst[@name='"+f+"']" + c;
|
||||
final String meta = pre + (rangeMode ? "/../" : "");
|
||||
|
||||
|
||||
// date faceting defaults to include both endpoints,
|
||||
// range faceting defaults to including only lower
|
||||
// doc exists with value @ 00:00:00.000 on July5
|
||||
final String jul4 = rangeMode ? "[.='1' ]" : "[.='2' ]";
|
||||
|
||||
assertQ("check counts for month of facet by day",
|
||||
req( "q", "*:*"
|
||||
,"rows", "0"
|
||||
|
@ -381,12 +387,10 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
,p+".other", "all"
|
||||
)
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 31 : 34)+"]"
|
||||
,pre+"/int[@name='1976-07-01T00:00:00Z'][.='0' ]"
|
||||
,pre+"/int[@name='1976-07-02T00:00:00Z'][.='0' ]"
|
||||
,pre+"/int[@name='1976-07-01T00:00:00Z'][.='0']"
|
||||
,pre+"/int[@name='1976-07-02T00:00:00Z'][.='0']"
|
||||
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
|
||||
// july4th = 2 because exists doc @ 00:00:00.000 on July5
|
||||
// (date faceting is inclusive)
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
|
||||
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0']"
|
||||
,pre+"/int[@name='1976-07-07T00:00:00Z'][.='0']"
|
||||
|
@ -433,9 +437,7 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
)
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 8 : 11)+"]"
|
||||
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
|
||||
// july4th = 2 because exists doc @ 00:00:00.000 on July5
|
||||
// (date faceting is inclusive)
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
|
||||
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-12T00:00:00Z'][.='1' ]"
|
||||
,pre+"/int[@name='1976-07-13T00:00:00Z'][.='1' ]"
|
||||
|
@ -458,11 +460,9 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
,p+".other", "all"
|
||||
,"f." + f + ".facet.mincount", "2"
|
||||
)
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 4 : 7)+"]"
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 3 : 7)+"]"
|
||||
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
|
||||
// july4th = 2 because exists doc @ 00:00:00.000 on July5
|
||||
// (date faceting is inclusive)
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
|
||||
,pre+(rangeMode ? "" : "/int[@name='1976-07-04T00:00:00Z']" +jul4)
|
||||
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-15T00:00:00Z'][.='2' ]"
|
||||
,meta+"/int[@name='before' ][.='2']"
|
||||
|
@ -482,11 +482,11 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
)
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 2 : 5)+"]"
|
||||
,pre+"/int[@name='1976-07-05T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0' ]"
|
||||
,pre+"/int[@name='1976-07-06T00:00:00Z'][.='0']"
|
||||
|
||||
,meta+"/int[@name='before' ][.='5']"
|
||||
);
|
||||
assertQ("check after is not inclusive of lower bound by default",
|
||||
assertQ("check after is not inclusive of lower bound by default (for dates)",
|
||||
req("q", "*:*"
|
||||
,"rows", "0"
|
||||
,"facet", "true"
|
||||
|
@ -498,9 +498,9 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
)
|
||||
,"*[count("+pre+"/int)="+(rangeMode ? 2 : 5)+"]"
|
||||
,pre+"/int[@name='1976-07-03T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z'][.='2' ]"
|
||||
,pre+"/int[@name='1976-07-04T00:00:00Z']" + jul4
|
||||
|
||||
,meta+"/int[@name='after' ][.='8']"
|
||||
,meta+"/int[@name='after' ][.='"+(rangeMode ? 9 : 8)+"']"
|
||||
);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue