Java Code Examples for org.apache.solr.common.util.NamedList#toString()

The following examples show how to use org.apache.solr.common.util.NamedList#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void multiValueTest() throws Exception {
  String[] params = new String[] {
      "o.multivalued.s.mean", "mean(int_id)",
      "o.multivalued.ff", "long_ldm",
      "o.multivalued.ff", "string_sdm",
      "o.multivalued.ff", "date_dtdm"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Long
  Collection<Double> lon = getValueList(response, "multivalued", "fieldFacets", "long_ldm", "mean", false);
  ArrayList<Double> longTest = calculateFacetedNumberStat(multiLongTestStart, "mean");
  assertEquals(responseStr,lon,longTest);
  //Date
  Collection<Double> date = getValueList(response, "multivalued", "fieldFacets", "date_dtdm", "mean", false);
  ArrayList<Double> dateTest = calculateFacetedNumberStat(multiDateTestStart, "mean");
  assertEquals(responseStr,date,dateTest);
  //String
  Collection<Double> string = getValueList(response, "multivalued", "fieldFacets", "string_sdm", "mean", false);
  ArrayList<Double> stringTest = calculateFacetedNumberStat(multiStringTestStart, "mean");
  assertEquals(responseStr,string,stringTest);
}
 
Example 2
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void meanTest() throws Exception {
  String[] params = new String[] {
      "o.mr.s.int_id", "mean(int_id)",
      "o.mr.s.long_ld", "mean(long_ld)",
      "o.mr.s.float_fd", "mean(float_fd)",
      "o.mr.s.double_dd", "mean(double_dd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Double intResult = getValue(response, "mr", "int_id");
  Double intTest = calculateNumberStat(intTestStart, "mean");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Double longResult = getValue(response, "mr", "long_ld");
  Double longTest = calculateNumberStat(longTestStart, "mean");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Double floatResult = getValue(response, "mr", "float_fd");
  Double floatTest = calculateNumberStat(floatTestStart, "mean");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Double doubleResult = getValue(response, "mr", "double_dd");
  Double doubleTest = calculateNumberStat(doubleTestStart, "mean");
  assertEquals(responseStr, doubleResult,doubleTest);
}
 
Example 3
Source File: LegacyFieldFacetExtrasCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void limitTest() throws Exception {
  String[] params = new String[] {
      "o.lr.s.mean", "mean(int_id)",
      "o.lr.s.median", "median(int_id)",
      "o.lr.s.count", "count(int_id)",
      "o.lr.s.percentile_20", "percentile(20,int_id)",
      "o.lr.ff.long_ld", "long_ld",
      "o.lr.ff.long_ld.ss", "mean",
      "o.lr.ff.long_ld.sd", "asc",
      "o.lr.ff.long_ld.limit", "5",
      "o.lr.ff.float_fd", "float_fd",
      "o.lr.ff.float_fd.ss", "median",
      "o.lr.ff.float_fd.sd", "desc",
      "o.lr.ff.float_fd.limit", "3",
      "o.lr.ff.double_dd", "double_dd",
      "o.lr.ff.double_dd.ss", "count",
      "o.lr.ff.double_dd.sd", "asc",
      "o.lr.ff.double_dd.limit", "7",
      "o.lr.ff.string_sd", "string_sd",
      "o.lr.ff.string_sd.ss", "percentile_20",
      "o.lr.ff.string_sd.sd", "desc",
      "o.lr.ff.string_sd.limit", "1"
  };

  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  Collection<Double> lon = getValueList(response, "lr", "fieldFacets", "long_ld", "mean", false);
  assertEquals(responseStr, lon.size(),5);
  Collection<Double> flo = getValueList(response, "lr", "fieldFacets", "float_fd", "median", false);
  assertEquals(responseStr, flo.size(),3);
  Collection<Long> doub = getValueList(response, "lr", "fieldFacets", "double_dd", "count", false);
  assertEquals(responseStr, doub.size(),7);
  Collection<Integer> string = getValueList(response, "lr", "fieldFacets", "string_sd", "percentile_20", false);
  assertEquals(responseStr, string.size(),1);
}
 
Example 4
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void missingDefaultTest() throws Exception {
  String[] params = new String[] {
      "o.misr.s.int_id", "missing(int_id)",
      "o.misr.s.long_ld", "missing(long_ld)",
      "o.misr.s.float_fd", "missing(float_fd)",
      "o.misr.s.double_dd", "missing(double_dd)",
      "o.misr.s.date_dtd", "missing(date_dtd)",
      "o.misr.s.string_sd", "missing(string_sd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  long intResult = getValue(response, "misr", "int_id");
  assertEquals(responseStr, intMissing,intResult);

  //Long
  long longResult = getValue(response, "misr", "long_ld");
  assertEquals(responseStr, longMissing,longResult);

  //Float
  long floatResult = getValue(response, "misr", "float_fd");
  assertEquals(responseStr, floatMissing,floatResult);

  //Double
  long doubleResult = getValue(response, "misr", "double_dd");
  assertEquals(responseStr, doubleMissing,doubleResult);

  //Date
  long dateResult = getValue(response, "misr", "date_dtd");
  assertEquals(responseStr, dateMissing,dateResult);

  //String
  long stringResult = getValue(response, "misr", "string_sd");
  assertEquals(responseStr, stringMissing, stringResult);
}
 
Example 5
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void medianTest() throws Exception {
  String[] params = new String[] {
      "o.medr.s.int_id", "median(int_id)",
      "o.medr.s.long_ld", "median(long_ld)",
      "o.medr.s.float_fd", "median(float_fd)",
      "o.medr.s.double_dd", "median(double_dd)",
      "o.medr.s.date_dtd", "median(date_dtd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Double intResult = getValue(response, "medr", "int_id");
  Double intTest = calculateNumberStat(intTestStart, "median");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Double longResult = getValue(response, "medr", "long_ld");
  Double longTest = calculateNumberStat(longTestStart, "median");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Double floatResult = getValue(response, "medr", "float_fd");
  Double floatTest = calculateNumberStat(floatTestStart, "median");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Double doubleResult = getValue(response, "medr", "double_dd");
  Double doubleTest = calculateNumberStat(doubleTestStart, "median");
  assertEquals(responseStr, doubleResult,doubleTest);

  // TODO: Add test for date median
}
 
Example 6
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void stddevTest() throws Exception {
  String[] params = new String[] {
      "o.str.s.int_id", "stddev(int_id)",
      "o.str.s.long_ld", "stddev(long_ld)",
      "o.str.s.float_fd", "stddev(float_fd)",
      "o.str.s.double_dd", "stddev(double_dd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Double intResult = getValue(response, "str", "int_id");
  Double intTest = calculateNumberStat(intTestStart, "stddev");
  assertEquals(responseStr, intResult, intTest, 0.00000000001);

  //Long
  Double longResult = getValue(response, "str", "long_ld");
  Double longTest = calculateNumberStat(longTestStart, "stddev");
  assertEquals(responseStr, longResult, longTest, 0.00000000001);

  //Float
  Double floatResult = getValue(response, "str", "float_fd");
  Double floatTest = calculateNumberStat(floatTestStart, "stddev");
  assertEquals(responseStr, floatResult, floatTest, 0.00000000001);


  //Double
  Double doubleResult = getValue(response, "str", "double_dd");
  Double doubleTest = calculateNumberStat(doubleTestStart, "stddev");
  assertEquals(responseStr, doubleResult, doubleTest, 0.00000000001);
}
 
Example 7
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void sumTest() throws Exception {
  String[] params = new String[] {
      "o.sr.s.int_id", "sum(int_id)",
      "o.sr.s.long_ld", "sum(long_ld)",
      "o.sr.s.float_fd", "sum(float_fd)",
      "o.sr.s.double_dd", "sum(double_dd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Double intResult = getValue(response, "sr", "int_id");
  Double intTest = calculateNumberStat(intTestStart, "sum");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Double longResult = getValue(response, "sr", "long_ld");
  Double longTest = calculateNumberStat(longTestStart, "sum");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Double floatResult = getValue(response, "sr", "float_fd");
  Double floatTest = calculateNumberStat(floatTestStart, "sum");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Double doubleResult = getValue(response, "sr", "double_dd");
  Double doubleTest = calculateNumberStat(doubleTestStart, "sum");
  assertEquals(responseStr, doubleResult,doubleTest);
}
 
Example 8
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void perc60Test() throws Exception {
  String[] params = new String[] {
      "o.p6r.s.int_id", "percentile(60,int_id)",
      "o.p6r.s.long_ld", "percentile(60,long_ld)",
      "o.p6r.s.float_fd", "percentile(60,float_fd)",
      "o.p6r.s.double_dd", "percentile(60,double_dd)",
      "o.p6r.s.date_dtd", "string(percentile(60,date_dtd))",
      "o.p6r.s.string_sd", "percentile(60,string_sd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int 60
  Integer intResult = getValue(response, "p6r", "int_id");
  Integer intTest = (Integer)calculateStat(intTestStart, "perc_60");
  assertEquals(responseStr, intResult,intTest);

  //Long 60
  Long longResult = getValue(response, "p6r", "long_ld");
  Long longTest = (Long)calculateStat(longTestStart, "perc_60");
  assertEquals(responseStr, longResult,longTest);

  //Float 60
  Float floatResult = getValue(response, "p6r", "float_fd");
  Float floatTest = (Float)calculateStat(floatTestStart, "perc_60");
  assertEquals(responseStr, floatResult,floatTest);

  //Double 60
  Double doubleResult = getValue(response, "p6r", "double_dd");
  Double doubleTest = (Double)calculateStat(doubleTestStart, "perc_60");
  assertEquals(responseStr, doubleResult,doubleTest);

  //Date 60
  String dateResult = getValue(response, "p6r", "date_dtd");
  String dateTest = (String)calculateStat(dateTestStart, "perc_60");
  assertEquals(responseStr, dateResult,dateTest);

  //String 60
  String stringResult = getValue(response, "p6r", "string_sd");
  String stringTest = (String)calculateStat(stringTestStart, "perc_60");
  assertEquals(responseStr, stringResult,stringTest);
}
 
Example 9
Source File: AddSchemaFieldsUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private static List<TypeMapping> parseTypeMappings(@SuppressWarnings({"rawtypes"})NamedList args) {
  List<TypeMapping> typeMappings = new ArrayList<>();
  @SuppressWarnings({"unchecked"})
  List<Object> typeMappingsParams = args.getAll(TYPE_MAPPING_PARAM);
  for (Object typeMappingObj : typeMappingsParams) {
    if (null == typeMappingObj) {
      throw new SolrException(SERVER_ERROR, "'" + TYPE_MAPPING_PARAM + "' init param cannot be null");
    }
    if ( ! (typeMappingObj instanceof NamedList) ) {
      throw new SolrException(SERVER_ERROR, "'" + TYPE_MAPPING_PARAM + "' init param must be a <lst>");
    }
    @SuppressWarnings({"rawtypes"})
    NamedList typeMappingNamedList = (NamedList)typeMappingObj;

    Object fieldTypeObj = typeMappingNamedList.remove(FIELD_TYPE_PARAM);
    if (null == fieldTypeObj) {
      throw new SolrException(SERVER_ERROR,
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> must contain a '" + FIELD_TYPE_PARAM + "' <str>");
    }
    if ( ! (fieldTypeObj instanceof CharSequence)) {
      throw new SolrException(SERVER_ERROR, "'" + FIELD_TYPE_PARAM + "' init param must be a <str>");
    }
    if (null != typeMappingNamedList.get(FIELD_TYPE_PARAM)) {
      throw new SolrException(SERVER_ERROR,
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> may contain only one '" + FIELD_TYPE_PARAM + "' <str>");
    }
    String fieldType = fieldTypeObj.toString();

    @SuppressWarnings({"unchecked"})
    Collection<String> valueClasses
        = typeMappingNamedList.removeConfigArgs(VALUE_CLASS_PARAM);
    if (valueClasses.isEmpty()) {
      throw new SolrException(SERVER_ERROR, 
          "Each '" + TYPE_MAPPING_PARAM + "' <lst/> must contain at least one '" + VALUE_CLASS_PARAM + "' <str>");
    }

    // isDefault (optional)
    Boolean isDefault = false;
    Object isDefaultObj = typeMappingNamedList.remove(IS_DEFAULT_PARAM);
    if (null != isDefaultObj) {
      if ( ! (isDefaultObj instanceof Boolean)) {
        throw new SolrException(SERVER_ERROR, "'" + IS_DEFAULT_PARAM + "' init param must be a <bool>");
      }
      if (null != typeMappingNamedList.get(IS_DEFAULT_PARAM)) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + IS_DEFAULT_PARAM + "' <bool>");
      }
      isDefault = Boolean.parseBoolean(isDefaultObj.toString());
    }
    
    Collection<CopyFieldDef> copyFieldDefs = new ArrayList<>(); 
    while (typeMappingNamedList.get(COPY_FIELD_PARAM) != null) {
      Object copyFieldObj = typeMappingNamedList.remove(COPY_FIELD_PARAM);
      if ( ! (copyFieldObj instanceof NamedList)) {
        throw new SolrException(SERVER_ERROR, "'" + COPY_FIELD_PARAM + "' init param must be a <lst>");
      }
      @SuppressWarnings({"rawtypes"})
      NamedList copyFieldNamedList = (NamedList)copyFieldObj;
      // dest
      Object destObj = copyFieldNamedList.remove(DEST_PARAM);
      if (null == destObj) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> must contain a '" + DEST_PARAM + "' <str>");
      }
      if ( ! (destObj instanceof CharSequence)) {
        throw new SolrException(SERVER_ERROR, "'" + COPY_FIELD_PARAM + "' init param must be a <str>");
      }
      if (null != copyFieldNamedList.get(COPY_FIELD_PARAM)) {
        throw new SolrException(SERVER_ERROR,
            "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + COPY_FIELD_PARAM + "' <str>");
      }
      String dest = destObj.toString();
      // maxChars (optional)
      Integer maxChars = 0;
      Object maxCharsObj = copyFieldNamedList.remove(MAX_CHARS_PARAM);
      if (null != maxCharsObj) {
        if ( ! (maxCharsObj instanceof Integer)) {
          throw new SolrException(SERVER_ERROR, "'" + MAX_CHARS_PARAM + "' init param must be a <int>");
        }
        if (null != copyFieldNamedList.get(MAX_CHARS_PARAM)) {
          throw new SolrException(SERVER_ERROR,
              "Each '" + COPY_FIELD_PARAM + "' <lst/> may contain only one '" + MAX_CHARS_PARAM + "' <str>");
        }
        maxChars = Integer.parseInt(maxCharsObj.toString());
      }
      copyFieldDefs.add(new CopyFieldDef(dest, maxChars));
    }
    typeMappings.add(new TypeMapping(fieldType, valueClasses, isDefault, copyFieldDefs));
    
    if (0 != typeMappingNamedList.size()) {
      throw new SolrException(SERVER_ERROR, 
          "Unexpected '" + TYPE_MAPPING_PARAM + "' init sub-param(s): '" + typeMappingNamedList.toString() + "'");
    }
    args.remove(TYPE_MAPPING_PARAM);
  }
  return typeMappings;
}
 
Example 10
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void maxTest() throws Exception {
  String[] params = new String[] {
      "o.mar.s.int_id", "max(int_id)",
      "o.mar.s.long_ld", "max(long_ld)",
      "o.mar.s.float_fd", "max(float_fd)",
      "o.mar.s.double_dd", "max(double_dd)",
      "o.mar.s.date_dtd", "string(max(date_dtd))",
      "o.mar.s.string_sd", "max(string_sd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Integer intResult = getValue(response, "mar", "int_id");
  Integer intTest = (Integer)calculateStat(intTestStart, "max");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Long longResult = getValue(response, "mar", "long_ld");
  Long longTest = (Long)calculateStat(longTestStart, "max");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Float floatResult = getValue(response, "mar", "float_fd");
  Float floatTest = (Float)calculateStat(floatTestStart, "max");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Double doubleResult = getValue(response, "mar", "double_dd");
  Double doubleTest = (Double)calculateStat(doubleTestStart, "max");
  assertEquals(responseStr, doubleResult,doubleTest);

  //Date
  String dateResult = getValue(response, "mar", "date_dtd");
  String dateTest = (String)calculateStat(dateTestStart, "max");
  assertEquals(responseStr, dateResult,dateTest);

  //String
  String stringResult = getValue(response, "mar", "string_sd");
  String stringTest = (String)calculateStat(stringTestStart, "max");
  assertEquals(responseStr, stringResult,stringTest);
}
 
Example 11
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void uniqueTest() throws Exception {
  String[] params = new String[] {
      "o.ur.s.int_id", "unique(int_id)",
      "o.ur.s.long_ld", "unique(long_ld)",
      "o.ur.s.float_fd", "unique(float_fd)",
      "o.ur.s.double_dd", "unique(double_dd)",
      "o.ur.s.date_dtd", "unique(date_dtd)",
      "o.ur.s.string_sd", "unique(string_sd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Long intResult = getValue(response, "ur", "int_id");
  Long intTest = (Long)calculateStat(intTestStart, "unique");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Long longResult = getValue(response, "ur", "long_ld");
  Long longTest = (Long)calculateStat(longTestStart, "unique");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Long floatResult = getValue(response, "ur", "float_fd");
  Long floatTest = (Long)calculateStat(floatTestStart, "unique");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Long doubleResult = getValue(response, "ur", "double_dd");
  Long doubleTest = (Long)calculateStat(doubleTestStart, "unique");
  assertEquals(responseStr, doubleResult,doubleTest);

  //Date
  Long dateResult = getValue(response, "ur", "date_dtd");
  Long dateTest = (Long)calculateStat(dateTestStart, "unique");
  assertEquals(responseStr, dateResult,dateTest);

  //String
  Long stringResult = getValue(response, "ur", "string_sd");
  Long stringTest = (Long)calculateStat(stringTestStart, "unique");
  assertEquals(responseStr, stringResult,stringTest);
}
 
Example 12
Source File: LegacyNoFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void countTest() throws Exception {
  String[] params = new String[] {
      "o.cr.s.int_id", "count(int_id)",
      "o.cr.s.long_ld", "count(long_ld)",
      "o.cr.s.float_fd", "count(float_fd)",
      "o.cr.s.double_dd", "count(double_dd)",
      "o.cr.s.date_dtd", "count(date_dtd)",
      "o.cr.s.string_sd", "count(string_sd)"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int
  Long intResult = getValue(response, "cr", "int_id");
  Long intTest = (Long)calculateStat(intTestStart, "count");
  assertEquals(responseStr, intResult,intTest);

  //Long
  Long longResult = getValue(response, "cr", "long_ld");
  Long longTest = (Long)calculateStat(longTestStart, "count");
  assertEquals(responseStr, longResult,longTest);

  //Float
  Long floatResult = getValue(response, "cr", "float_fd");
  Long floatTest = (Long)calculateStat(floatTestStart, "count");
  assertEquals(responseStr, floatResult,floatTest);

  //Double
  Long doubleResult = getValue(response, "cr", "double_dd");
  Long doubleTest = (Long)calculateStat(doubleTestStart, "count");
  assertEquals(responseStr, doubleResult,doubleTest);

  //Date
  Long dateResult = getValue(response, "cr", "date_dtd");
  Long dateTest = (Long)calculateStat(dateTestStart, "count");
  assertEquals(responseStr, dateResult,dateTest);

  //String
  Long stringResult = getValue(response, "cr", "string_sd");
  Long stringTest = (Long)calculateStat(stringTestStart, "count");
  assertEquals(responseStr, stringResult,stringTest);
}
 
Example 13
Source File: LegacyQueryFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void queryTest() throws Exception {
  String[] params = new String[] {
      "o.ir.s.sum", "sum(int_id)",
      "o.ir.s.mean", "mean(int_id)",
      "o.ir.s.median", "median(int_id)",
      "o.ir.s.percentile_8", "percentile(8,int_id)",
      "o.ir.qf", "float1",
      "o.ir.qf.float1.q", "float_fd:[* TO 50]",
      "o.ir.qf", "float2",
      "o.ir.qf.float2.q", "float_fd:[* TO 30]",

      "o.lr.s.sum", "sum(long_ld)",
      "o.lr.s.mean", "mean(long_ld)",
      "o.lr.s.median", "median(long_ld)",
      "o.lr.s.percentile_8", "percentile(8,long_ld)",
      "o.lr.qf", "string",
      "o.lr.qf.string.q", "string_sd:abc1",
      "o.lr.qf.string.q", "string_sd:abc2",

      "o.fr.s.sum", "sum(float_fd)",
      "o.fr.s.mean", "mean(float_fd)",
      "o.fr.s.median", "median(float_fd)",
      "o.fr.s.percentile_8", "percentile(8,float_fd)",
      "o.fr.qf", "lad",
      "o.fr.qf.lad.q", "long_ld:[20 TO *]",
      "o.fr.qf.lad.q", "long_ld:[30 TO *]",
      "o.fr.qf.lad.q", "double_dd:[* TO 50]"
  };

  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int One
  ArrayList<Double> int1 = getValueList(response, "ir", "queryFacets", "float1", "sum", false);
  ArrayList<Double> int1Test = calculateFacetedNumberStat(int1TestStart, "sum");
  assertEquals(responseStr, int1, int1Test);
  //Int Two
  ArrayList<Integer> int2 = getValueList(response, "ir", "queryFacets", "float2", "percentile_8", false);
  ArrayList<Integer> int2Test = (ArrayList<Integer>)calculateFacetedStat(int2TestStart, "perc_8");
  assertEquals(responseStr, int2, int2Test);

  //Long
  ArrayList<Double> long1 = getValueList(response, "lr", "queryFacets", "string", "median", false);
  ArrayList<Double> long1Test = calculateFacetedNumberStat(longTestStart, "median");
  assertEquals(responseStr,long1,long1Test);

  //Float
  ArrayList<Double> float1 = getValueList(response, "fr", "queryFacets", "lad", "mean", false);
  ArrayList<Double> float1Test = calculateFacetedNumberStat(floatTestStart, "mean");
  assertEquals(responseStr, float1, float1Test);
}
 
Example 14
Source File: LegacyRangeFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void rangeTest() throws Exception {
  String[] params = new String[] {
      "o.ri.s.sum", "sum(int_id)",
      "o.ri.s.mean", "mean(int_id)",
      "o.ri.s.median", "median(int_id)",
      "o.ri.s.count", "count(int_id)",
      "o.ri.rf", "long_ld",
      "o.ri.rf.long_ld.st", "5",
      "o.ri.rf.long_ld.e", "30",
      "o.ri.rf.long_ld.g", "5",
      "o.ri.rf.long_ld.ib", "lower",
      "o.ri.rf.long_ld.or", "all",
      "o.ri.rf", "double_dd",
      "o.ri.rf.double_dd.st", "3",
      "o.ri.rf.double_dd.e", "39",
      "o.ri.rf.double_dd.g", "7",
      "o.ri.rf.double_dd.ib", "upper",
      "o.ri.rf.double_dd.ib", "outer",
      "o.ri.rf.double_dd.or", "all",
      "o.ri.rf", "date_dtd",
      "o.ri.rf.date_dtd.st", "1007-01-01T23:59:59Z",
      "o.ri.rf.date_dtd.e", "1044-01-01T23:59:59Z",
      "o.ri.rf.date_dtd.g", "+7YEARS",
      "o.ri.rf.date_dtd.ib", "lower",
      "o.ri.rf.date_dtd.ib", "edge",
      "o.ri.rf.date_dtd.ib", "outer",
      "o.ri.rf.date_dtd.or", "all",

      "o.rf.s.sum", "sum(float_fd)",
      "o.rf.s.mean", "mean(float_fd)",
      "o.rf.s.median", "median(float_fd)",
      "o.rf.s.count", "count(float_fd)",
      "o.rf.rf", "long_ld",
      "o.rf.rf.long_ld.st", "0",
      "o.rf.rf.long_ld.e", "29",
      "o.rf.rf.long_ld.g", "4",
      "o.rf.rf.long_ld.ib", "all",
      "o.rf.rf.long_ld.or", "all",
      "o.rf.rf", "double_dd",
      "o.rf.rf.double_dd.st", "4",
      "o.rf.rf.double_dd.e", "47",
      "o.rf.rf.double_dd.g", "11",
      "o.rf.rf.double_dd.ib", "edge",
      "o.rf.rf.double_dd.or", "all",
      "o.rf.rf", "date_dtd",
      "o.rf.rf.date_dtd.st", "1004-01-01T23:59:59Z",
      "o.rf.rf.date_dtd.e", "1046-01-01T23:59:59Z",
      "o.rf.rf.date_dtd.g", "+5YEARS",
      "o.rf.rf.date_dtd.ib", "upper",
      "o.rf.rf.date_dtd.ib", "edge",
      "o.rf.rf.date_dtd.or", "all"
  };

  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Long
  ArrayList<Long> intLong = getValueList(response, "ri", "rangeFacets", "long_ld", "count", false);
  ArrayList<Long> intLongTest = calculateFacetedStat(transformLists(intLongTestStart, 5, 30, 5
                                                      , false, true, false, false, false), "count");
  assertEquals(responseStr, intLong,intLongTest);
  //Int Double
  ArrayList<Double> intDouble = getValueList(response, "ri", "rangeFacets", "double_dd", "mean", false);
  ArrayList<Double> intDoubleTest = calculateFacetedNumberStat(transformLists(intDoubleTestStart, 3, 39, 7
                                                        , false, false, true, false, true), "mean");
  assertEquals(responseStr, intDouble,intDoubleTest);
  //Int Date
  ArrayList<Long> intDate = getValueList(response, "ri", "rangeFacets", "date_dtd", "count", false);
  ArrayList<Long> intDateTest = (ArrayList<Long>)calculateFacetedStat(transformLists(intDateTestStart, 7, 44, 7
                                                    , false, true, false, true, true), "count");
  assertEquals(responseStr, intDate,intDateTest);

  //Float Long
  ArrayList<Double> floatLong = getValueList(response, "rf", "rangeFacets", "long_ld", "median", false);
  ArrayList<Double> floatLongTest = calculateFacetedNumberStat(transformLists(floatLongTestStart, 0, 29, 4
                                                        , false, true, true, true, true), "median");
  assertEquals(responseStr, floatLong,floatLongTest);
  //Float Double
  ArrayList<Long> floatDouble = getValueList(response, "rf", "rangeFacets", "double_dd", "count", false);
  ArrayList<Long> floatDoubleTest = (ArrayList<Long>)calculateFacetedStat(transformLists(floatDoubleTestStart, 4, 47, 11
                                                                   , false, false, false, true, false), "count");
  assertEquals(responseStr, floatDouble,floatDoubleTest);
}
 
Example 15
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void minTest() throws Exception {
  String[] params = new String[] {
      "o.minn.s.int", "min(int_id)",
      "o.minn.s.long", "min(long_ld)",
      "o.minn.s.float", "min(float_fd)",
      "o.minn.s.double", "min(double_dd)",
      "o.minn.ff", "string_sd",
      "o.minn.ff", "date_dtd",

      "o.min.s.str", "min(string_sd)",
      "o.min.s.date", "string(min(date_dtd))",
      "o.min.ff", "int_id",
      "o.min.ff", "long_ld"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Date
  Collection<Integer> intDate = getValueList(response, "minn", "fieldFacets", "date_dtd", "int", false);
  ArrayList<Integer> intDateTest = (ArrayList<Integer>)calculateFacetedStat(intDateTestStart, "min");
  assertEquals(responseStr,intDate,intDateTest);
  //Int String
  Collection<Integer> intString = getValueList(response, "minn", "fieldFacets", "string_sd", "int", false);
  ArrayList<Integer> intStringTest = (ArrayList<Integer>)calculateFacetedStat(intStringTestStart, "min");
  assertEquals(responseStr,intString,intStringTest);

  //Long Date
  Collection<Long> longDate = getValueList(response, "minn", "fieldFacets", "date_dtd", "long", false);
  ArrayList<Long> longDateTest = (ArrayList<Long>)calculateFacetedStat(longDateTestStart, "min");
  assertEquals(responseStr,longDate,longDateTest);
  //Long String
  Collection<Long> longString = getValueList(response, "minn", "fieldFacets", "string_sd", "long", false);
  ArrayList<Long> longStringTest = (ArrayList<Long>)calculateFacetedStat(longStringTestStart, "min");
  assertEquals(responseStr,longString,longStringTest);

  //Float Date
  Collection<Float> floatDate = getValueList(response, "minn", "fieldFacets", "date_dtd", "float", false);
  ArrayList<Float> floatDateTest = (ArrayList<Float>)calculateFacetedStat(floatDateTestStart, "min");
  assertEquals(responseStr,floatDate,floatDateTest);
  //Float String
  Collection<Float> floatString = getValueList(response, "minn", "fieldFacets", "string_sd", "float", false);
  ArrayList<Float> floatStringTest = (ArrayList<Float>)calculateFacetedStat(floatStringTestStart, "min");
  assertEquals(responseStr,floatString,floatStringTest);

  //Double Date
  Collection<Double> doubleDate = getValueList(response, "minn", "fieldFacets", "date_dtd", "double", false);
  ArrayList<Double> doubleDateTest = (ArrayList<Double>)calculateFacetedStat(doubleDateTestStart, "min");
  assertEquals(responseStr,doubleDate,doubleDateTest);
  //Double String
  Collection<Double> doubleString = getValueList(response, "minn", "fieldFacets", "string_sd", "double", false);
  ArrayList<Double> doubleStringTest = (ArrayList<Double>)calculateFacetedStat(doubleStringTestStart, "min");
  assertEquals(responseStr,doubleString,doubleStringTest);

  //Date Int
  Collection<String> dateInt = getValueList(response, "min", "fieldFacets", "int_id", "date", false);
  ArrayList<String> dateIntTest = (ArrayList<String>)calculateFacetedStat(dateIntTestStart, "min");
  assertEquals(responseStr,dateInt,dateIntTest);
  //Date Long
  Collection<String> dateString = getValueList(response, "min", "fieldFacets", "long_ld", "date", false);
  ArrayList<String> dateLongTest = (ArrayList<String>)calculateFacetedStat(dateLongTestStart, "min");
  assertEquals(responseStr,dateString,dateLongTest);

  //String Int
  Collection<String> stringInt = getValueList(response, "min", "fieldFacets", "int_id", "str", false);
  ArrayList<String> stringIntTest = (ArrayList<String>)calculateFacetedStat(stringIntTestStart, "min");
  assertEquals(responseStr,stringInt,stringIntTest);
  //String Long
  Collection<String> stringLong = getValueList(response, "min", "fieldFacets", "long_ld", "str", false);
  ArrayList<String> stringLongTest = (ArrayList<String>)calculateFacetedStat(stringLongTestStart, "min");
  assertEquals(responseStr,stringLong,stringLongTest);
}
 
Example 16
Source File: LegacyRangeFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void multiGapTest() throws Exception {
  String[] params = new String[] {
      "o.mi.s.sum", "sum(int_id)",
      "o.mi.s.mean", "mean(int_id)",
      "o.mi.s.median", "median(int_id)",
      "o.mi.s.count", "count(int_id)",
      "o.mi.rf", "long_ld",
      "o.mi.rf.long_ld.st", "5",
      "o.mi.rf.long_ld.e", "30",
      "o.mi.rf.long_ld.g", "4,2,6,3",
      "o.mi.rf.long_ld.ib", "lower",
      "o.mi.rf.long_ld.or", "all",
      "o.mi.rf", "double_dd",
      "o.mi.rf.double_dd.st", "3",
      "o.mi.rf.double_dd.e", "39",
      "o.mi.rf.double_dd.g", "3,1,7",
      "o.mi.rf.double_dd.ib", "upper",
      "o.mi.rf.double_dd.ib", "outer",
      "o.mi.rf.double_dd.or", "all",
      "o.mi.rf", "date_dtd",
      "o.mi.rf.date_dtd.st", "1007-01-01T23:59:59Z",
      "o.mi.rf.date_dtd.e", "1044-01-01T23:59:59Z",
      "o.mi.rf.date_dtd.g", "+2YEARS,+7YEARS",
      "o.mi.rf.date_dtd.ib", "lower",
      "o.mi.rf.date_dtd.ib", "edge",
      "o.mi.rf.date_dtd.ib", "outer",
      "o.mi.rf.date_dtd.or", "all",

      "o.mf.s.sum", "sum(float_fd)",
      "o.mf.s.mean", "mean(float_fd)",
      "o.mf.s.median", "median(float_fd)",
      "o.mf.s.count", "count(float_fd)",
      "o.mf.rf", "long_ld",
      "o.mf.rf.long_ld.st", "0",
      "o.mf.rf.long_ld.e", "29",
      "o.mf.rf.long_ld.g", "1,4",
      "o.mf.rf.long_ld.ib", "all",
      "o.mf.rf.long_ld.or", "all",
      "o.mf.rf", "double_dd",
      "o.mf.rf.double_dd.st", "4",
      "o.mf.rf.double_dd.e", "47",
      "o.mf.rf.double_dd.g", "2,3,11",
      "o.mf.rf.double_dd.ib", "edge",
      "o.mf.rf.double_dd.or", "all",
      "o.mf.rf", "date_dtd",
      "o.mf.rf.date_dtd.st", "1004-01-01T23:59:59Z",
      "o.mf.rf.date_dtd.e", "1046-01-01T23:59:59Z",
      "o.mf.rf.date_dtd.g", "+4YEARS,+5YEARS",
      "o.mf.rf.date_dtd.ib", "upper",
      "o.mf.rf.date_dtd.ib", "edge",
      "o.mf.rf.date_dtd.or", "all"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Long
  ArrayList<Double> intLong = getValueList(response, "mi", "rangeFacets", "long_ld", "sum", false);
  ArrayList<Double> intLongTest = calculateFacetedNumberStat(transformLists(intLongTestStart, 5, 30, "4,2,6,3"
                                                      , false, true, false, false, false), "sum");
  assertEquals(responseStr, intLong,intLongTest);
  //Int Double
  ArrayList<Double> intDouble = getValueList(response, "mi", "rangeFacets", "double_dd", "mean", false);
  ArrayList<Double> intDoubleTest = calculateFacetedNumberStat(transformLists(intDoubleTestStart, 3, 39, "3,1,7"
                                                        , false, false, true, false, true), "mean");
  assertEquals(responseStr, intDouble,intDoubleTest);
  //Int Date
  ArrayList<Long> intDate = getValueList(response, "mi", "rangeFacets", "date_dtd", "count", false);
  ArrayList<Long> intDateTest = (ArrayList<Long>)calculateFacetedStat(transformLists(intDateTestStart, 7, 44, "2,7"
                                                    , false, true, false, true, true), "count");
  assertEquals(responseStr, intDate,intDateTest);

  //Float Long
  ArrayList<Double> floatLong = getValueList(response, "mf", "rangeFacets", "long_ld", "median", false);
  ArrayList<Double> floatLongTest = calculateFacetedNumberStat(transformLists(floatLongTestStart, 0, 29, "1,4"
                                                        , false, true, true, true, true), "median");;
  assertEquals(responseStr, floatLong,floatLongTest);
  //Float Double
  ArrayList<Long> floatDouble = getValueList(response, "mf", "rangeFacets", "double_dd", "count", false);
  ArrayList<Long> floatDoubleTest = (ArrayList<Long>)calculateFacetedStat(transformLists(floatDoubleTestStart, 4, 47, "2,3,11"
                                                        , false, false, false, true, false), "count");
  assertEquals(responseStr, floatDouble,floatDoubleTest);
}
 
Example 17
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void meanTest() throws Exception {
  String[] params = new String[] {
      "o.mean.s.int", "mean(int_id)",
      "o.mean.s.long", "mean(long_ld)",
      "o.mean.s.float", "mean(float_fd)",
      "o.mean.s.double", "mean(double_dd)",
      "o.mean.ff", "string_sd",
      "o.mean.ff", "date_dtd"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Date
  Collection<Double> intDate = getValueList(response, "mean", "fieldFacets", "date_dtd", "int", false);
  ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "mean");
  assertEquals(responseStr,intDate,intDateTest);
  //Int String
  Collection<Double> intString = getValueList(response, "mean", "fieldFacets", "string_sd", "int", false);
  ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "mean");
  assertEquals(responseStr,intString,intStringTest);

  //Long Date
  Collection<Double> longDate = getValueList(response, "mean", "fieldFacets", "date_dtd", "long", false);
  ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "mean");
  assertEquals(responseStr,longDate,longDateTest);
  //Long String
  Collection<Double> longString = getValueList(response, "mean", "fieldFacets", "string_sd", "long", false);
  ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "mean");
  assertEquals(responseStr,longString,longStringTest);

  //Float Date
  Collection<Double> floatDate = getValueList(response, "mean", "fieldFacets", "date_dtd", "float", false);
  ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "mean");
  assertEquals(responseStr,floatDate,floatDateTest);
  //Float String
  Collection<Double> floatString = getValueList(response, "mean", "fieldFacets", "string_sd", "float", false);
  ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "mean");
  assertEquals(responseStr,floatString,floatStringTest);

  //Double Date
  Collection<Double> doubleDate = getValueList(response, "mean", "fieldFacets", "date_dtd", "double", false);
  ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "mean");
  assertEquals(responseStr,doubleDate,doubleDateTest);
  //Double String
  Collection<Double> doubleString = getValueList(response, "mean", "fieldFacets", "string_sd", "double", false);
  ArrayList<Double> doubleStringTest = calculateFacetedNumberStat(doubleStringTestStart, "mean");
  assertEquals(responseStr,doubleString,doubleStringTest);
}
 
Example 18
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void medianFacetAscTest() throws Exception {
  String[] params = new String[] {
      "o.median.s.int", "median(int_id)",
      "o.median.s.long", "median(long_ld)",
      "o.median.s.float", "median(float_fd)",
      "o.median.s.double", "median(double_dd)",
      "o.median.ff", "string_sd",
      "o.median.ff", "date_dtd"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Date
  Collection<Double> intDate = getValueList(response, "median","fieldFacets", "date_dtd", "int", false);
  ArrayList<Double> intDateTest = calculateFacetedNumberStat(intDateTestStart, "median");
  assertEquals(responseStr,intDate,intDateTest);
  //Int String
  Collection<Double> intString = getValueList(response, "median", "fieldFacets", "string_sd", "int", false);
  ArrayList<Double> intStringTest = calculateFacetedNumberStat(intStringTestStart, "median");
  assertEquals(responseStr,intString,intStringTest);

  //Long Date
  Collection<Double> longDate = getValueList(response, "median", "fieldFacets", "date_dtd", "long", false);
  ArrayList<Double> longDateTest = calculateFacetedNumberStat(longDateTestStart, "median");
  assertEquals(responseStr,longDate,longDateTest);
  //Long String
  Collection<Double> longString = getValueList(response, "median", "fieldFacets", "string_sd", "long", false);
  ArrayList<Double> longStringTest = calculateFacetedNumberStat(longStringTestStart, "median");
  assertEquals(responseStr,longString,longStringTest);

  //Float Date
  Collection<Double> floatDate = getValueList(response, "median", "fieldFacets", "date_dtd", "float", false);
  ArrayList<Double> floatDateTest = calculateFacetedNumberStat(floatDateTestStart, "median");
  assertEquals(responseStr,floatDate,floatDateTest);
  //Float String
  Collection<Double> floatString = getValueList(response, "median", "fieldFacets", "string_sd", "float", false);
  ArrayList<Double> floatStringTest = calculateFacetedNumberStat(floatStringTestStart, "median");
  assertEquals(responseStr,floatString,floatStringTest);

  //Double Date
  Collection<Double> doubleDate = getValueList(response, "median", "fieldFacets", "date_dtd", "double", false);
  ArrayList<Double> doubleDateTest = calculateFacetedNumberStat(doubleDateTestStart, "median");
  assertEquals(responseStr,doubleDate,doubleDateTest);
  //Double String
  Collection<Double> doubleString = getValueList(response, "median", "fieldFacets", "string_sd", "double", false);
  ArrayList<Double> doubleStringTest = calculateFacetedNumberStat(doubleStringTestStart, "median");
  assertEquals(responseStr,doubleString,doubleStringTest);
}
 
Example 19
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void perc20Test() throws Exception {
  String[] params = new String[] {
      "o.percentile_20n.s.int", "percentile(20,int_id)",
      "o.percentile_20n.s.long", "percentile(20,long_ld)",
      "o.percentile_20n.s.float", "percentile(20,float_fd)",
      "o.percentile_20n.s.double", "percentile(20,double_dd)",
      "o.percentile_20n.ff", "string_sd",
      "o.percentile_20n.ff", "date_dtd",

      "o.percentile_20.s.str", "percentile(20,string_sd)",
      "o.percentile_20.s.date", "string(percentile(20,date_dtd))",
      "o.percentile_20.ff", "int_id",
      "o.percentile_20.ff", "long_ld"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Date
  Collection<Integer> intDate = getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "int", false);
  ArrayList<Integer> intDateTest = (ArrayList<Integer>)calculateFacetedStat(intDateTestStart, "perc_20");
  assertEquals(responseStr,intDate,intDateTest);
  //Int String
  Collection<Integer> intString = getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "int", false);
  ArrayList<Integer> intStringTest = (ArrayList<Integer>)calculateFacetedStat(intStringTestStart, "perc_20");
  assertEquals(responseStr,intString,intStringTest);

  //Long Date
  Collection<Long> longDate = getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "long", false);
  ArrayList<Long> longDateTest = (ArrayList<Long>)calculateFacetedStat(longDateTestStart, "perc_20");
  assertEquals(responseStr,longDate,longDateTest);
  //Long String
  Collection<Long> longString = getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "long", false);
  ArrayList<Long> longStringTest = (ArrayList<Long>)calculateFacetedStat(longStringTestStart, "perc_20");
  assertEquals(responseStr,longString,longStringTest);

  //Float Date
  Collection<Float> floatDate = getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "float", false);
  ArrayList<Float> floatDateTest = (ArrayList<Float>)calculateFacetedStat(floatDateTestStart, "perc_20");
  assertEquals(responseStr,floatDate,floatDateTest);
  //Float String
  Collection<Float> floatString = getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "float", false);
  ArrayList<Float> floatStringTest = (ArrayList<Float>)calculateFacetedStat(floatStringTestStart, "perc_20");
  assertEquals(responseStr,floatString,floatStringTest);

  //Double Date
  Collection<Double> doubleDate = getValueList(response, "percentile_20n", "fieldFacets", "date_dtd", "double", false);
  ArrayList<Double> doubleDateTest = (ArrayList<Double>)calculateFacetedStat(doubleDateTestStart, "perc_20");
  assertEquals(responseStr,doubleDate,doubleDateTest);
  //Double String
  Collection<Double> doubleString = getValueList(response, "percentile_20n", "fieldFacets", "string_sd", "double", false);
  ArrayList<Double> doubleStringTest = (ArrayList<Double>)calculateFacetedStat(doubleStringTestStart, "perc_20");
  assertEquals(responseStr,doubleString,doubleStringTest);

  //Date Int
  Collection<String> dateInt = getValueList(response, "percentile_20", "fieldFacets", "int_id", "date", false);
  ArrayList<String> dateIntTest = (ArrayList<String>)calculateFacetedStat(dateIntTestStart, "perc_20");
  assertEquals(responseStr,dateInt,dateIntTest);
  //Date Long
  Collection<String> dateString = getValueList(response, "percentile_20", "fieldFacets", "long_ld", "date", false);
  ArrayList<String> dateLongTest = (ArrayList<String>)calculateFacetedStat(dateLongTestStart, "perc_20");
  assertEquals(responseStr,dateString,dateLongTest);

  //String Int
  Collection<String> stringInt = getValueList(response, "percentile_20", "fieldFacets", "int_id", "str", false);
  ArrayList<String> stringIntTest = (ArrayList<String>)calculateFacetedStat(stringIntTestStart, "perc_20");
  assertEquals(responseStr,stringInt,stringIntTest);
  //String Long
  Collection<String> stringLong = getValueList(response, "percentile_20", "fieldFacets", "long_ld", "str", false);
  ArrayList<String> stringLongTest = (ArrayList<String>)calculateFacetedStat(stringLongTestStart, "perc_20");
  assertEquals(responseStr,stringLong,stringLongTest);
}
 
Example 20
Source File: LegacyFieldFacetCloudTest.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void perc60Test() throws Exception {
  String[] params = new String[] {
      "o.percentile_60n.s.int", "percentile(60,int_id)",
      "o.percentile_60n.s.long", "percentile(60,long_ld)",
      "o.percentile_60n.s.float", "percentile(60,float_fd)",
      "o.percentile_60n.s.double", "percentile(60,double_dd)",
      "o.percentile_60n.ff", "string_sd",
      "o.percentile_60n.ff", "date_dtd",

      "o.percentile_60.s.str", "percentile(60,string_sd)",
      "o.percentile_60.s.date", "string(percentile(60,date_dtd))",
      "o.percentile_60.ff", "int_id",
      "o.percentile_60.ff", "long_ld"
  };
  NamedList<Object> response = queryLegacyCloudAnalytics(params);
  String responseStr = response.toString();

  //Int Date
  Collection<Integer> intDate = getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "int", false);
  ArrayList<Integer> intDateTest = (ArrayList<Integer>)calculateFacetedStat(intDateTestStart, "perc_60");
  assertEquals(responseStr,intDate,intDateTest);
  //Int String
  Collection<Integer> intString = getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "int", false);
  ArrayList<Integer> intStringTest = (ArrayList<Integer>)calculateFacetedStat(intStringTestStart, "perc_60");
  assertEquals(responseStr,intString,intStringTest);

  //Long Date
  Collection<Long> longDate = getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "long", false);
  ArrayList<Long> longDateTest = (ArrayList<Long>)calculateFacetedStat(longDateTestStart, "perc_60");
  assertEquals(responseStr,longDate,longDateTest);
  //Long String
  Collection<Long> longString = getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "long", false);
  ArrayList<Long> longStringTest = (ArrayList<Long>)calculateFacetedStat(longStringTestStart, "perc_60");
  assertEquals(responseStr,longString,longStringTest);

  //Float Date
  Collection<Float> floatDate = getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "float", false);
  ArrayList<Float> floatDateTest = (ArrayList<Float>)calculateFacetedStat(floatDateTestStart, "perc_60");
  assertEquals(responseStr,floatDate,floatDateTest);
  //Float String
  Collection<Float> floatString = getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "float", false);
  ArrayList<Float> floatStringTest = (ArrayList<Float>)calculateFacetedStat(floatStringTestStart, "perc_60");
  assertEquals(responseStr,floatString,floatStringTest);

  //Double Date
  Collection<Double> doubleDate = getValueList(response, "percentile_60n", "fieldFacets", "date_dtd", "double", false);
  ArrayList<Double> doubleDateTest = (ArrayList<Double>)calculateFacetedStat(doubleDateTestStart, "perc_60");
  assertEquals(responseStr,doubleDate,doubleDateTest);
  //Double String
  Collection<Double> doubleString = getValueList(response, "percentile_60n", "fieldFacets", "string_sd", "double", false);
  ArrayList<Double> doubleStringTest = (ArrayList<Double>)calculateFacetedStat(doubleStringTestStart, "perc_60");
  assertEquals(responseStr,doubleString,doubleStringTest);

  //Date Int
  Collection<String> dateInt = getValueList(response, "percentile_60", "fieldFacets", "int_id", "date", false);
  ArrayList<String> dateIntTest = (ArrayList<String>)calculateFacetedStat(dateIntTestStart, "perc_60");
  assertEquals(responseStr,dateInt,dateIntTest);
  //Date Long
  Collection<String> dateString = getValueList(response, "percentile_60", "fieldFacets", "long_ld", "date", false);
  ArrayList<String> dateLongTest = (ArrayList<String>)calculateFacetedStat(dateLongTestStart, "perc_60");
  assertEquals(responseStr,dateString,dateLongTest);

  //String Int
  Collection<String> stringInt = getValueList(response, "percentile_60", "fieldFacets", "int_id", "str", false);
  ArrayList<String> stringIntTest = (ArrayList<String>)calculateFacetedStat(stringIntTestStart, "perc_60");
  assertEquals(responseStr,stringInt,stringIntTest);
  //String Long
  Collection<String> stringLong = getValueList(response, "percentile_60", "fieldFacets", "long_ld", "str", false);
  ArrayList<String> stringLongTest = (ArrayList<String>)calculateFacetedStat(stringLongTestStart, "perc_60");
  assertEquals(responseStr,stringLong,stringLongTest);
}