mirror of https://github.com/apache/lucene.git
SOLR-10123: Fix to better support numeric PointFields. Unit tests now use randomized numeric fields.
Closes #215
This commit is contained in:
parent
b200ba5bf4
commit
88b7ed1d46
|
@ -449,7 +449,7 @@ public class ExpressionFactory {
|
|||
}
|
||||
} else if (fieldType instanceof TrieIntField) {
|
||||
if (multivalued) {
|
||||
aField = new IntMultiField(fieldName);
|
||||
aField = new IntMultiTrieField(fieldName);
|
||||
} else {
|
||||
aField = new IntField(fieldName);
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ public class ExpressionFactory {
|
|||
}
|
||||
} else if (fieldType instanceof TrieLongField) {
|
||||
if (multivalued) {
|
||||
aField = new LongMultiField(fieldName);
|
||||
aField = new LongMultiTrieField(fieldName);
|
||||
} else {
|
||||
aField = new LongField(fieldName);
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ public class ExpressionFactory {
|
|||
}
|
||||
} else if (fieldType instanceof TrieFloatField) {
|
||||
if (multivalued) {
|
||||
aField = new FloatMultiField(fieldName);
|
||||
aField = new FloatMultiTrieField(fieldName);
|
||||
} else {
|
||||
aField = new FloatField(fieldName);
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ public class ExpressionFactory {
|
|||
}
|
||||
} else if (fieldType instanceof TrieDoubleField) {
|
||||
if (multivalued) {
|
||||
aField = new DoubleMultiField(fieldName);
|
||||
aField = new DoubleMultiTrieField(fieldName);
|
||||
} else {
|
||||
aField = new DoubleField(fieldName);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ public class ExpressionFactory {
|
|||
}
|
||||
} else if (fieldType instanceof TrieDateField) {
|
||||
if (multivalued) {
|
||||
aField = new DateMultiField(fieldName);
|
||||
aField = new DateMultiTrieField(fieldName);
|
||||
} else {
|
||||
aField = new DateField(fieldName);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import org.apache.solr.schema.TrieDateField;
|
|||
/**
|
||||
* An analytics wrapper for a multi-valued {@link TrieDateField} with DocValues enabled.
|
||||
*/
|
||||
public class DateMultiField extends LongMultiField implements CastingDateValueStream {
|
||||
public class DateMultiTrieField extends LongMultiTrieField implements CastingDateValueStream {
|
||||
|
||||
public DateMultiField(String fieldName) {
|
||||
public DateMultiTrieField(String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
|
@ -31,12 +31,12 @@ import org.apache.solr.schema.TrieDoubleField;
|
|||
/**
|
||||
* An analytics wrapper for a multi-valued {@link TrieDoubleField} with DocValues enabled.
|
||||
*/
|
||||
public class DoubleMultiField extends AnalyticsField implements CastingDoubleValueStream {
|
||||
public class DoubleMultiTrieField extends AnalyticsField implements CastingDoubleValueStream {
|
||||
private SortedSetDocValues docValues;
|
||||
private int count;
|
||||
private double[] values;
|
||||
|
||||
public DoubleMultiField(String fieldName) {
|
||||
public DoubleMultiTrieField(String fieldName) {
|
||||
super(fieldName);
|
||||
count = 0;
|
||||
values = new double[initialArrayLength];
|
|
@ -32,12 +32,12 @@ import org.apache.solr.schema.TrieFloatField;
|
|||
/**
|
||||
* An analytics wrapper for a multi-valued {@link TrieFloatField} with DocValues enabled.
|
||||
*/
|
||||
public class FloatMultiField extends AnalyticsField implements CastingFloatValueStream {
|
||||
public class FloatMultiTrieField extends AnalyticsField implements CastingFloatValueStream {
|
||||
private SortedSetDocValues docValues;
|
||||
private int count;
|
||||
private float[] values;
|
||||
|
||||
public FloatMultiField(String fieldName) {
|
||||
public FloatMultiTrieField(String fieldName) {
|
||||
super(fieldName);
|
||||
count = 0;
|
||||
values = new float[initialArrayLength];
|
|
@ -33,12 +33,12 @@ import org.apache.solr.schema.TrieIntField;
|
|||
/**
|
||||
* An analytics wrapper for a multi-valued {@link TrieIntField} with DocValues enabled.
|
||||
*/
|
||||
public class IntMultiField extends AnalyticsField implements CastingIntValueStream {
|
||||
public class IntMultiTrieField extends AnalyticsField implements CastingIntValueStream {
|
||||
private SortedSetDocValues docValues;
|
||||
private int count;
|
||||
private int[] values;
|
||||
|
||||
public IntMultiField(String fieldName) {
|
||||
public IntMultiTrieField(String fieldName) {
|
||||
super(fieldName);
|
||||
count = 0;
|
||||
values = new int[initialArrayLength];
|
|
@ -31,12 +31,12 @@ import org.apache.solr.schema.TrieLongField;
|
|||
/**
|
||||
* An analytics wrapper for a multi-valued {@link TrieLongField} with DocValues enabled.
|
||||
*/
|
||||
public class LongMultiField extends AnalyticsField implements CastingLongValueStream {
|
||||
public class LongMultiTrieField extends AnalyticsField implements CastingLongValueStream {
|
||||
private SortedSetDocValues docValues;
|
||||
private int count;
|
||||
private long[] values;
|
||||
|
||||
public LongMultiField(String fieldName) {
|
||||
public LongMultiTrieField(String fieldName) {
|
||||
super(fieldName);
|
||||
count = 0;
|
||||
values = new long[initialArrayLength];
|
|
@ -27,9 +27,8 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.params.FacetParams.FacetRangeInclude;
|
||||
import org.apache.solr.common.params.FacetParams.FacetRangeOther;
|
||||
import org.apache.solr.schema.FieldType;
|
||||
import org.apache.solr.schema.NumericFieldType;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.schema.TrieDateField;
|
||||
import org.apache.solr.schema.TrieField;
|
||||
import org.apache.solr.util.DateMathParser;
|
||||
|
||||
|
||||
|
@ -249,7 +248,7 @@ public abstract class FacetRangeGenerator<T extends Comparable<T>> {
|
|||
final SchemaField sf = rangeFacet.getField();
|
||||
final FieldType ft = sf.getType();
|
||||
final FacetRangeGenerator<?> calc;
|
||||
if (ft instanceof TrieField) {
|
||||
if (ft instanceof NumericFieldType) {
|
||||
switch (ft.getNumberType()) {
|
||||
case FLOAT:
|
||||
calc = new FloatFacetRangeGenerator(rangeFacet);
|
||||
|
@ -267,10 +266,10 @@ public abstract class FacetRangeGenerator<T extends Comparable<T>> {
|
|||
calc = new DateFacetRangeGenerator(rangeFacet, null);
|
||||
break;
|
||||
default:
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + sf.getName());
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on numeric field of unexpected type: " + sf.getName());
|
||||
}
|
||||
} else {
|
||||
throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
|
||||
throw new SolrException (SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on non-numeric field: " + sf);
|
||||
}
|
||||
return calc;
|
||||
}
|
||||
|
@ -330,9 +329,6 @@ class DateFacetRangeGenerator extends FacetRangeGenerator<Date> {
|
|||
public DateFacetRangeGenerator(final RangeFacet rangeFacet, final Date now) {
|
||||
super(rangeFacet);
|
||||
this.now = now;
|
||||
if (! (field.getType() instanceof TrieDateField) ) {
|
||||
throw new IllegalArgumentException("SchemaField must use field type extending TrieDateField");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
These are provided more for backward compatability, allowing one
|
||||
to create a schema that matches an existing lucene index.
|
||||
-->
|
||||
<fieldType name="int" class="${solr.tests.IntegerFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="float" class="${solr.tests.FloatFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="long" class="${solr.tests.LongFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="double" class="${solr.tests.DoubleFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="int" class="${solr.tests.IntegerFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="float" class="${solr.tests.FloatFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="long" class="${solr.tests.LongFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="double" class="${solr.tests.DoubleFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional
|
||||
seconds part (.999) is optional.
|
||||
-->
|
||||
<fieldType name="date" class="${solr.tests.DateFieldType}" docValues="${solr.tests.numeric.dv}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="date" class="${solr.tests.DateFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
|
||||
<fieldType name="boolean" class="solr.BoolField"/>
|
||||
<fieldType name="string" class="solr.StrField"/>
|
||||
|
|
|
@ -20,21 +20,16 @@
|
|||
|
||||
<schema name="cloud-analytics" version="1.0">
|
||||
|
||||
<fieldType name="int" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
|
||||
<fieldType name="float" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
|
||||
<fieldType name="long" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
|
||||
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
|
||||
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
|
||||
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
|
||||
|
||||
<!-- format for date is 1995-12-31T23:59:59.999Z and only the fractional
|
||||
seconds part (.999) is optional.
|
||||
-->
|
||||
<fieldType name="date" class="solr.TrieDateField" sortMissingLast="true" precisionStep="6"/>
|
||||
|
||||
|
||||
<fieldType name="int" class="${solr.tests.IntegerFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
|
||||
<fieldType name="float" class="${solr.tests.FloatFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
|
||||
<fieldType name="long" class="${solr.tests.LongFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="double" class="${solr.tests.DoubleFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
|
||||
<fieldType name="date" class="${solr.tests.DateFieldType}" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
|
||||
|
||||
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
|
||||
<field name="signatureField" type="string" indexed="true" stored="false"/>
|
||||
|
||||
<!-- for versioning -->
|
||||
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
|
||||
public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
||||
public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest {
|
||||
public static final int INT = 71;
|
||||
public static final int LONG = 36;
|
||||
public static final int LONGM = 50;
|
||||
|
@ -132,6 +132,8 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
multiStringTestMissing = new ArrayList<>();
|
||||
multiDateTestStart = new ArrayList<>();
|
||||
multiDateTestMissing = new ArrayList<>();
|
||||
|
||||
boolean multiCanHaveDuplicates = Boolean.getBoolean(NUMERIC_POINTS_SYSPROP);
|
||||
|
||||
UpdateRequest req = new UpdateRequest();
|
||||
for (int j = 0; j < NUM_LOOPS; ++j) {
|
||||
|
@ -148,8 +150,6 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
List<String> fields = new ArrayList<>();
|
||||
fields.add("id"); fields.add("1000"+j);
|
||||
|
||||
if (dt != 0) {
|
||||
}
|
||||
if( i != 0 ) {
|
||||
fields.add("int_id"); fields.add("" + i);
|
||||
}
|
||||
|
@ -180,16 +180,13 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
if ( sm != 0 ) {
|
||||
fields.add("string_sdm"); fields.add("str" + sm);
|
||||
}
|
||||
if ( dtm != 0 ) {
|
||||
fields.add("date_dtdm"); fields.add((1800+dtm) + "-12-31T23:59:59Z");
|
||||
}
|
||||
req.add(fields.toArray(new String[0]));
|
||||
|
||||
if( dt != 0 ){
|
||||
if( dt != 0 ) {
|
||||
//Dates
|
||||
if (j-DATE<0) {
|
||||
if ( j-DATE < 0 ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
intDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -197,7 +194,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
intDateTestStart.add(list1);
|
||||
ArrayList<Long> list2 = new ArrayList<>();
|
||||
if( l != 0l ){
|
||||
if( l != 0l ) {
|
||||
list2.add(l);
|
||||
longDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -205,7 +202,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
longDateTestStart.add(list2);
|
||||
ArrayList<Float> list3 = new ArrayList<>();
|
||||
if ( f != 0.0f ){
|
||||
if ( f != 0.0f ) {
|
||||
list3.add(f);
|
||||
floatDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -214,7 +211,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
floatDateTestStart.add(list3);
|
||||
ArrayList<Double> list4 = new ArrayList<>();
|
||||
if( d != 0.0d ){
|
||||
if( d != 0.0d ) {
|
||||
list4.add(d);
|
||||
doubleDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -222,7 +219,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
doubleDateTestStart.add(list4);
|
||||
ArrayList<Integer> list5 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list5.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -239,24 +236,26 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
}
|
||||
|
||||
if (j-DATEM<0 && dtm!=dt && dtm!=0) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
list1.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
multiDateTestMissing.add(1l);
|
||||
if ( dtm != 0 ) {
|
||||
if ( j-DATEM < 0 && dtm != dt ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
multiDateTestMissing.add(1l);
|
||||
}
|
||||
multiDateTestStart.add(list1);
|
||||
} else if ( dtm != dt || multiCanHaveDuplicates ) {
|
||||
if( i != 0 ) multiDateTestStart.get(dtm-1).add(i); else increment(multiDateTestMissing,dtm-1);
|
||||
}
|
||||
multiDateTestStart.add(list1);
|
||||
} else if (dtm!=dt && dtm!=0) {
|
||||
if( i != 0 ) multiDateTestStart.get(dtm-1).add(i);
|
||||
}
|
||||
|
||||
if( s != 0 ){
|
||||
//Strings
|
||||
if (j-STRING<0) {
|
||||
if ( j-STRING < 0 ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
intStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -264,7 +263,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
intStringTestStart.add(list1);
|
||||
ArrayList<Long> list2 = new ArrayList<>();
|
||||
if( l != 0l ){
|
||||
if( l != 0l ) {
|
||||
list2.add(l);
|
||||
longStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -280,7 +279,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
floatStringTestStart.add(list3);
|
||||
ArrayList<Double> list4 = new ArrayList<>();
|
||||
if( d != 0.0d ){
|
||||
if( d != 0.0d ) {
|
||||
list4.add(d);
|
||||
doubleStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -288,7 +287,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
doubleStringTestStart.add(list4);
|
||||
ArrayList<Integer> list5 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list5.add(i);
|
||||
multiStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -306,7 +305,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
|
||||
//Strings
|
||||
if( sm != 0 ){
|
||||
if (j-STRINGM<0&&sm!=s) {
|
||||
if ( j-STRINGM < 0 && sm != s ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
list1.add(i);
|
||||
|
@ -315,14 +314,14 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
multiStringTestMissing.add(1l);
|
||||
}
|
||||
multiStringTestStart.add(list1);
|
||||
} else if (sm!=s) {
|
||||
} else if ( sm != s ) {
|
||||
if( i != 0 ) multiStringTestStart.get(sm-1).add(i); else increment(multiStringTestMissing,sm-1);
|
||||
}
|
||||
}
|
||||
|
||||
//Int
|
||||
if( i != 0 ){
|
||||
if (j-INT<0) {
|
||||
if( i != 0 ) {
|
||||
if ( j-INT < 0 ) {
|
||||
ArrayList<String> list1 = new ArrayList<>();
|
||||
if( dt != 0 ){
|
||||
list1.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
|
@ -332,7 +331,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
dateIntTestStart.add(list1);
|
||||
ArrayList<String> list2 = new ArrayList<>();
|
||||
if( s != 0 ){
|
||||
if( s != 0 ) {
|
||||
list2.add("str"+s);
|
||||
stringIntTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -346,8 +345,8 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
|
||||
//Long
|
||||
if( l != 0 ){
|
||||
if (j-LONG<0) {
|
||||
if( l != 0 ) {
|
||||
if ( j-LONG < 0 ) {
|
||||
ArrayList<String> list1 = new ArrayList<>();
|
||||
if( dt != 0 ){
|
||||
list1.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
|
@ -357,7 +356,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
dateLongTestStart.add(list1);
|
||||
ArrayList<String> list2 = new ArrayList<>();
|
||||
if( s != 0 ){
|
||||
if( s != 0 ) {
|
||||
list2.add("str"+s);
|
||||
stringLongTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -365,7 +364,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
stringLongTestStart.add(list2);
|
||||
ArrayList<Integer> list3 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list3.add(i);
|
||||
multiLongTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -380,17 +379,17 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
|
||||
//Long
|
||||
if( lm != 0 ){
|
||||
if (j-LONGM<0&&lm!=l) {
|
||||
if( lm != 0 ) {
|
||||
if ( j-LONGM < 0 && lm != l ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
multiLongTestMissing.add(0l);
|
||||
} else {
|
||||
multiLongTestMissing.add(1l);
|
||||
}
|
||||
multiLongTestStart.add(list1);
|
||||
} else if (lm!=l) {
|
||||
} else if ( lm != l || multiCanHaveDuplicates ) {
|
||||
if( i != 0 ) multiLongTestStart.get((int)lm-1).add(i); else increment( multiLongTestMissing,(int)lm-1);
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +847,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
//Int Date
|
||||
Collection<Integer> intDate = getValueList(response, "maxn", "fieldFacets", "date_dtd", "int", false);
|
||||
ArrayList<Integer> intDateTest = (ArrayList<Integer>)calculateStat(intDateTestStart, "max");
|
||||
//assertEquals(responseStr,intDate,intDateTest);
|
||||
assertEquals(responseStr,intDate,intDateTest);
|
||||
|
||||
//Int String
|
||||
Collection<Integer> intString = getValueList(response, "maxn", "fieldFacets", "string_sd", "int", false);
|
||||
|
@ -1061,7 +1060,6 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
assertEquals(responseStr,stringLong,stringLongTest);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void missingTest() throws Exception {
|
||||
String[] params = new String[] {
|
||||
|
@ -1165,7 +1163,6 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
@Test
|
||||
public void missingFacetTest() throws Exception {
|
||||
String[] params = new String[] {
|
||||
"o.func.facet_show_missing(a)", "fillmissing(a,\"(MISSING)\")",
|
||||
"o.missingf.s.mean", "mean(int_id)",
|
||||
"o.missingf.ff", "date_dtd",
|
||||
"o.missingf.ff", "string_sd",
|
||||
|
@ -1206,6 +1203,7 @@ public class FieldFacetCloudTest extends AbstractAnalyticsFacetCloudTest{
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static void assertEquals(String mes, Object actual, Object expected) {
|
||||
Collections.sort((List<Comparable>) actual);
|
||||
Collections.sort((List<Comparable>) expected);
|
||||
|
|
|
@ -141,6 +141,8 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
multiStringTestMissing = new ArrayList<>();
|
||||
multiDateTestStart = new ArrayList<>();
|
||||
multiDateTestMissing = new ArrayList<>();
|
||||
|
||||
boolean multiCanHaveDuplicates = Boolean.getBoolean(NUMERIC_POINTS_SYSPROP);
|
||||
|
||||
for (int j = 0; j < NUM_LOOPS; ++j) {
|
||||
int i = j%INT;
|
||||
|
@ -152,32 +154,48 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
int dtm = j%DATEM;
|
||||
int s = j%STRING;
|
||||
int sm = j%STRINGM;
|
||||
if (dt==0 && dtm == 0) {
|
||||
assertU(adoc(filter("id", "1000" + j, "int_id", "" + i, "long_ld", "" + l, "float_fd", "" + f,
|
||||
"double_dd", "" + d, "date_dtd", (1800+dt) + "-12-31T23:59:59Z", "string_sd", "str" + s,
|
||||
"long_ldm", "" + l, "long_ldm", ""+lm, "string_sdm", "str" + s, "string_sdm", "str"+sm)));
|
||||
} else if (dt == 0) {
|
||||
assertU(adoc(filter("id", "1000" + j, "int_id", "" + i, "long_ld", "" + l, "float_fd", "" + f,
|
||||
"double_dd", "" + d, "date_dtd", (1800+dt) + "-12-31T23:59:59Z", "string_sd", "str" + s,
|
||||
"long_ldm", "" + l, "long_ldm", ""+lm, "string_sdm", "str" + s, "string_sdm", "str"+sm,
|
||||
"date_dtdm", (1800+dtm) + "-12-31T23:59:59Z")));
|
||||
} else if (dtm == 0) {
|
||||
assertU(adoc(filter("id", "1000" + j, "int_id", "" + i, "long_ld", "" + l, "float_fd", "" + f,
|
||||
"double_dd", "" + d, "date_dtd", (1800+dt) + "-12-31T23:59:59Z", "string_sd", "str" + s,
|
||||
"long_ldm", "" + l, "long_ldm", ""+lm, "string_sdm", "str" + s, "string_sdm", "str"+sm,
|
||||
"date_dtdm", (1800+dt) + "-12-31T23:59:59Z")));
|
||||
} else {
|
||||
assertU(adoc(filter("id", "1000" + j, "int_id", "" + i, "long_ld", "" + l, "float_fd", "" + f,
|
||||
"double_dd", "" + d, "date_dtd", (1800+dt) + "-12-31T23:59:59Z", "string_sd", "str" + s,
|
||||
"long_ldm", "" + l, "long_ldm", ""+lm, "string_sdm", "str" + s, "string_sdm", "str"+sm,
|
||||
"date_dtdm", (1800+dt) + "-12-31T23:59:59Z", "date_dtdm", (1800+dtm) + "-12-31T23:59:59Z")));
|
||||
}
|
||||
|
||||
if( dt != 0 ){
|
||||
|
||||
List<String> fields = new ArrayList<>();
|
||||
fields.add("id"); fields.add("1000"+j);
|
||||
|
||||
if( i != 0 ) {
|
||||
fields.add("int_id"); fields.add("" + i);
|
||||
}
|
||||
if( l != 0l ) {
|
||||
fields.add("long_ld"); fields.add("" + l);
|
||||
fields.add("long_ldm"); fields.add("" + l);
|
||||
}
|
||||
if( lm != 0l ) {
|
||||
fields.add("long_ldm"); fields.add("" + lm);
|
||||
}
|
||||
if( f != 0.0f ) {
|
||||
fields.add("float_fd"); fields.add("" + f);
|
||||
}
|
||||
if( d != 0.0d ) {
|
||||
fields.add("double_dd"); fields.add("" + d);
|
||||
}
|
||||
if( dt != 0 ) {
|
||||
fields.add("date_dtd"); fields.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
fields.add("date_dtdm"); fields.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
}
|
||||
if ( dtm != 0 ) {
|
||||
fields.add("date_dtdm"); fields.add((1800+dtm) + "-12-31T23:59:59Z");
|
||||
}
|
||||
if ( s != 0 ) {
|
||||
fields.add("string_sd"); fields.add("str" + s);
|
||||
fields.add("string_sdm"); fields.add("str" + s);
|
||||
}
|
||||
if ( sm != 0 ) {
|
||||
fields.add("string_sdm"); fields.add("str" + sm);
|
||||
}
|
||||
assertU(adoc(fields.toArray(new String[0])));
|
||||
|
||||
if( dt != 0 ) {
|
||||
//Dates
|
||||
if (j-DATE<0) {
|
||||
if ( j-DATE < 0 ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
intDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -185,7 +203,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
intDateTestStart.add(list1);
|
||||
ArrayList<Long> list2 = new ArrayList<>();
|
||||
if( l != 0l ){
|
||||
if( l != 0l ) {
|
||||
list2.add(l);
|
||||
longDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -193,7 +211,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
longDateTestStart.add(list2);
|
||||
ArrayList<Float> list3 = new ArrayList<>();
|
||||
if ( f != 0.0f ){
|
||||
if ( f != 0.0f ) {
|
||||
list3.add(f);
|
||||
floatDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -202,7 +220,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
floatDateTestStart.add(list3);
|
||||
ArrayList<Double> list4 = new ArrayList<>();
|
||||
if( d != 0.0d ){
|
||||
if( d != 0.0d ) {
|
||||
list4.add(d);
|
||||
doubleDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -210,7 +228,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
doubleDateTestStart.add(list4);
|
||||
ArrayList<Integer> list5 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list5.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -227,24 +245,26 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
}
|
||||
|
||||
if (j-DATEM<0 && dtm!=dt && dtm!=0) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
list1.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
multiDateTestMissing.add(1l);
|
||||
if ( dtm != 0 ) {
|
||||
if ( j-DATEM < 0 && dtm != dt ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
multiDateTestMissing.add(0l);
|
||||
} else {
|
||||
multiDateTestMissing.add(1l);
|
||||
}
|
||||
multiDateTestStart.add(list1);
|
||||
} else if ( dtm != dt || multiCanHaveDuplicates ) {
|
||||
if( i != 0 ) multiDateTestStart.get(dtm-1).add(i); else increment(multiDateTestMissing,dtm-1);
|
||||
}
|
||||
multiDateTestStart.add(list1);
|
||||
} else if (dtm!=dt && dtm!=0) {
|
||||
if( i != 0 ) multiDateTestStart.get(dtm-1).add(i);
|
||||
}
|
||||
|
||||
if( s != 0 ){
|
||||
//Strings
|
||||
if (j-STRING<0) {
|
||||
if ( j-STRING < 0 ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
intStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -252,7 +272,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
intStringTestStart.add(list1);
|
||||
ArrayList<Long> list2 = new ArrayList<>();
|
||||
if( l != 0l ){
|
||||
if( l != 0l ) {
|
||||
list2.add(l);
|
||||
longStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -268,7 +288,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
floatStringTestStart.add(list3);
|
||||
ArrayList<Double> list4 = new ArrayList<>();
|
||||
if( d != 0.0d ){
|
||||
if( d != 0.0d ) {
|
||||
list4.add(d);
|
||||
doubleStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -276,7 +296,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
doubleStringTestStart.add(list4);
|
||||
ArrayList<Integer> list5 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list5.add(i);
|
||||
multiStringTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -294,7 +314,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
|
||||
//Strings
|
||||
if( sm != 0 ){
|
||||
if (j-STRINGM<0&&sm!=s) {
|
||||
if ( j-STRINGM < 0 && sm != s ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
list1.add(i);
|
||||
|
@ -303,14 +323,14 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
multiStringTestMissing.add(1l);
|
||||
}
|
||||
multiStringTestStart.add(list1);
|
||||
} else if (sm!=s) {
|
||||
} else if ( sm != s ) {
|
||||
if( i != 0 ) multiStringTestStart.get(sm-1).add(i); else increment(multiStringTestMissing,sm-1);
|
||||
}
|
||||
}
|
||||
|
||||
//Int
|
||||
if( i != 0 ){
|
||||
if (j-INT<0) {
|
||||
if( i != 0 ) {
|
||||
if ( j-INT < 0 ) {
|
||||
ArrayList<String> list1 = new ArrayList<>();
|
||||
if( dt != 0 ){
|
||||
list1.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
|
@ -320,7 +340,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
dateIntTestStart.add(list1);
|
||||
ArrayList<String> list2 = new ArrayList<>();
|
||||
if( s != 0 ){
|
||||
if( s != 0 ) {
|
||||
list2.add("str"+s);
|
||||
stringIntTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -334,8 +354,8 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
|
||||
//Long
|
||||
if( l != 0 ){
|
||||
if (j-LONG<0) {
|
||||
if( l != 0 ) {
|
||||
if ( j-LONG < 0 ) {
|
||||
ArrayList<String> list1 = new ArrayList<>();
|
||||
if( dt != 0 ){
|
||||
list1.add((1800+dt) + "-12-31T23:59:59Z");
|
||||
|
@ -345,7 +365,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
dateLongTestStart.add(list1);
|
||||
ArrayList<String> list2 = new ArrayList<>();
|
||||
if( s != 0 ){
|
||||
if( s != 0 ) {
|
||||
list2.add("str"+s);
|
||||
stringLongTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -353,7 +373,7 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
stringLongTestStart.add(list2);
|
||||
ArrayList<Integer> list3 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list3.add(i);
|
||||
multiLongTestMissing.add(0l);
|
||||
} else {
|
||||
|
@ -368,17 +388,17 @@ public class FieldFacetTest extends AbstractAnalyticsFacetTest{
|
|||
}
|
||||
|
||||
//Long
|
||||
if( lm != 0 ){
|
||||
if (j-LONGM<0&&lm!=l) {
|
||||
if( lm != 0 ) {
|
||||
if ( j-LONGM < 0 && lm != l ) {
|
||||
ArrayList<Integer> list1 = new ArrayList<>();
|
||||
if( i != 0 ){
|
||||
if( i != 0 ) {
|
||||
list1.add(i);
|
||||
multiLongTestMissing.add(0l);
|
||||
} else {
|
||||
multiLongTestMissing.add(1l);
|
||||
}
|
||||
multiLongTestStart.add(list1);
|
||||
} else if (lm!=l) {
|
||||
} else if ( lm != l || multiCanHaveDuplicates ) {
|
||||
if( i != 0 ) multiLongTestStart.get((int)lm-1).add(i); else increment( multiLongTestMissing,(int)lm-1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue