mirror of https://github.com/apache/lucene.git
SOLR-4776: Solrj doesn't return 'between' count in range facets
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1477637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13c05812fc
commit
429a056988
|
@ -74,6 +74,9 @@ Bug Fixes
|
||||||
* SOLR-4752: There are some minor bugs in the Collections API parameter
|
* SOLR-4752: There are some minor bugs in the Collections API parameter
|
||||||
validation. (Mark Miller)
|
validation. (Mark Miller)
|
||||||
|
|
||||||
|
* SOLR-4776: Solrj doesn't return "between" count in range facets
|
||||||
|
(Philip K. Warren via shalin)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -314,8 +314,9 @@ public class QueryResponse extends SolrResponseBase
|
||||||
|
|
||||||
Number before = (Number) values.get("before");
|
Number before = (Number) values.get("before");
|
||||||
Number after = (Number) values.get("after");
|
Number after = (Number) values.get("after");
|
||||||
|
Number between = (Number) values.get("between");
|
||||||
|
|
||||||
rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after);
|
rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after, between);
|
||||||
} else {
|
} else {
|
||||||
String gap = (String) rawGap;
|
String gap = (String) rawGap;
|
||||||
Date start = (Date) values.get("start");
|
Date start = (Date) values.get("start");
|
||||||
|
@ -323,8 +324,9 @@ public class QueryResponse extends SolrResponseBase
|
||||||
|
|
||||||
Number before = (Number) values.get("before");
|
Number before = (Number) values.get("before");
|
||||||
Number after = (Number) values.get("after");
|
Number after = (Number) values.get("after");
|
||||||
|
Number between = (Number) values.get("between");
|
||||||
|
|
||||||
rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after);
|
rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after, between);
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedList<Integer> counts = (NamedList<Integer>) values.get("counts");
|
NamedList<Integer> counts = (NamedList<Integer>) values.get("counts");
|
||||||
|
|
|
@ -34,14 +34,16 @@ public abstract class RangeFacet<B, G> {
|
||||||
|
|
||||||
private final Number before;
|
private final Number before;
|
||||||
private final Number after;
|
private final Number after;
|
||||||
|
private final Number between;
|
||||||
|
|
||||||
protected RangeFacet(String name, B start, B end, G gap, Number before, Number after) {
|
protected RangeFacet(String name, B start, B end, G gap, Number before, Number after, Number between) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.gap = gap;
|
this.gap = gap;
|
||||||
this.before = before;
|
this.before = before;
|
||||||
this.after = after;
|
this.after = after;
|
||||||
|
this.between = between;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCount(String value, int count) {
|
public void addCount(String value, int count) {
|
||||||
|
@ -76,18 +78,32 @@ public abstract class RangeFacet<B, G> {
|
||||||
return after;
|
return after;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Number getBetween() {
|
||||||
|
return between;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Numeric extends RangeFacet<Number, Number> {
|
public static class Numeric extends RangeFacet<Number, Number> {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Numeric(String name, Number start, Number end, Number gap, Number before, Number after) {
|
public Numeric(String name, Number start, Number end, Number gap, Number before, Number after) {
|
||||||
super(name, start, end, gap, before, after);
|
this(name, start, end, gap, before, after, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Numeric(String name, Number start, Number end, Number gap, Number before, Number after, Number between) {
|
||||||
|
super(name, start, end, gap, before, after, between);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Date extends RangeFacet<java.util.Date, String> {
|
public static class Date extends RangeFacet<java.util.Date, String> {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after) {
|
public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after) {
|
||||||
super(name, start, end, gap, before, after);
|
this(name, start, end, gap, before, after, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after, Number between) {
|
||||||
|
super(name, start, end, gap, before, after, between);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,8 @@
|
||||||
<date name="end">2008-02-13T15:26:37Z</date>
|
<date name="end">2008-02-13T15:26:37Z</date>
|
||||||
<int name="before">90</int>
|
<int name="before">90</int>
|
||||||
<int name="after">1</int>
|
<int name="after">1</int>
|
||||||
|
<int name="between">11</int>
|
||||||
</lst>
|
</lst>
|
||||||
</lst>
|
</lst>
|
||||||
</lst>
|
</lst>
|
||||||
</response>
|
</response>
|
||||||
|
|
|
@ -114,6 +114,7 @@ public class QueryResponseTest extends LuceneTestCase {
|
||||||
assertEquals(0, manufacturedateDt.getCounts().get(2).getCount());
|
assertEquals(0, manufacturedateDt.getCounts().get(2).getCount());
|
||||||
assertEquals(90, manufacturedateDt.getBefore());
|
assertEquals(90, manufacturedateDt.getBefore());
|
||||||
assertEquals(1, manufacturedateDt.getAfter());
|
assertEquals(1, manufacturedateDt.getAfter());
|
||||||
|
assertEquals(11, manufacturedateDt.getBetween());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue