mirror of https://github.com/apache/lucene.git
SOLR-2818: Added before/after count response parsing support for range facets in SolrJ.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1180377 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
40426f3464
commit
9ccc145128
|
@ -357,6 +357,9 @@ New Features
|
||||||
* SOLR-1979: New contrib "langid". Adds language identification capabilities as an
|
* SOLR-1979: New contrib "langid". Adds language identification capabilities as an
|
||||||
Update Processor, using Tika's LanguageIdentifier (janhoy, Tommaso Teofili, gsingers)
|
Update Processor, using Tika's LanguageIdentifier (janhoy, Tommaso Teofili, gsingers)
|
||||||
|
|
||||||
|
* SOLR-2818: Added before/after count response parsing support for range facets in
|
||||||
|
SolrJ. (Bernhard Frauendienst via Martijn van Groningen)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-2748: The CommitTracker used for commitWith or autoCommit by maxTime
|
* SOLR-2748: The CommitTracker used for commitWith or autoCommit by maxTime
|
||||||
|
|
|
@ -311,12 +311,20 @@ public class QueryResponse extends SolrResponseBase
|
||||||
Number gap = (Number) rawGap;
|
Number gap = (Number) rawGap;
|
||||||
Number start = (Number) values.get("start");
|
Number start = (Number) values.get("start");
|
||||||
Number end = (Number) values.get("end");
|
Number end = (Number) values.get("end");
|
||||||
rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap);
|
|
||||||
|
Number before = (Number) values.get("before");
|
||||||
|
Number after = (Number) values.get("after");
|
||||||
|
|
||||||
|
rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after);
|
||||||
} else {
|
} else {
|
||||||
String gap = (String) rawGap;
|
String gap = (String) rawGap;
|
||||||
Date start = (Date) values.get("start");
|
Date start = (Date) values.get("start");
|
||||||
Date end = (Date) values.get("end");
|
Date end = (Date) values.get("end");
|
||||||
rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap);
|
|
||||||
|
Number before = (Number) values.get("before");
|
||||||
|
Number after = (Number) values.get("after");
|
||||||
|
|
||||||
|
rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
NamedList<Integer> counts = (NamedList<Integer>) values.get("counts");
|
NamedList<Integer> counts = (NamedList<Integer>) values.get("counts");
|
||||||
|
|
|
@ -32,11 +32,16 @@ public abstract class RangeFacet<B, G> {
|
||||||
private final B end;
|
private final B end;
|
||||||
private final G gap;
|
private final G gap;
|
||||||
|
|
||||||
protected RangeFacet(String name, B start, B end, G gap) {
|
private final Number before;
|
||||||
|
private final Number after;
|
||||||
|
|
||||||
|
protected RangeFacet(String name, B start, B end, G gap, Number before, Number after) {
|
||||||
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.after = after;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCount(String value, int count) {
|
public void addCount(String value, int count) {
|
||||||
|
@ -63,19 +68,26 @@ public abstract class RangeFacet<B, G> {
|
||||||
return gap;
|
return gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Number getBefore() {
|
||||||
|
return before;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Number getAfter() {
|
||||||
|
return after;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Numeric extends RangeFacet<Number, Number> {
|
public static class Numeric extends RangeFacet<Number, Number> {
|
||||||
|
|
||||||
public Numeric(String name, Number start, Number end, Number gap) {
|
public Numeric(String name, Number start, Number end, Number gap, Number before, Number after) {
|
||||||
super(name, start, end, gap);
|
super(name, start, end, gap, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Date extends RangeFacet<java.util.Date, String> {
|
public static class Date extends RangeFacet<java.util.Date, String> {
|
||||||
|
|
||||||
public Date(String name, java.util.Date start, java.util.Date end, String gap) {
|
public Date(String name, java.util.Date start, java.util.Date end, String gap, Number before, Number after) {
|
||||||
super(name, start, end, gap);
|
super(name, start, end, gap, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@
|
||||||
<str name="gap">+1YEAR</str>
|
<str name="gap">+1YEAR</str>
|
||||||
<date name="start">2005-02-13T15:26:37Z</date>
|
<date name="start">2005-02-13T15:26:37Z</date>
|
||||||
<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="after">1</int>
|
||||||
</lst>
|
</lst>
|
||||||
</lst>
|
</lst>
|
||||||
</lst>
|
</lst>
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class QueryResponseTest extends LuceneTestCase {
|
||||||
assertEquals(7, manufacturedateDt.getCounts().get(1).getCount());
|
assertEquals(7, manufacturedateDt.getCounts().get(1).getCount());
|
||||||
assertEquals("2007-02-13T15:26:37Z", manufacturedateDt.getCounts().get(2).getValue());
|
assertEquals("2007-02-13T15:26:37Z", manufacturedateDt.getCounts().get(2).getValue());
|
||||||
assertEquals(0, manufacturedateDt.getCounts().get(2).getCount());
|
assertEquals(0, manufacturedateDt.getCounts().get(2).getCount());
|
||||||
|
assertEquals(90, manufacturedateDt.getBefore());
|
||||||
|
assertEquals(1, manufacturedateDt.getAfter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue