Example usage for org.apache.solr.client.solrj.response FieldStatsInfo getStddev

List of usage examples for org.apache.solr.client.solrj.response FieldStatsInfo getStddev

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response FieldStatsInfo getStddev.

Prototype

public Double getStddev() 

Source Link

Usage

From source file:com.frank.search.solr.core.ResultHelper.java

License:Apache License

private static <T extends SimpleStatsResult> T populateStatsResultWithFieldStatsInfo(T statsResult,
        FieldStatsInfo value) {

    statsResult.setMax(value.getMax());//w  ww.  j  a  v  a2s  . co m
    statsResult.setMin(value.getMin());
    statsResult.setCount(value.getCount());
    statsResult.setMissing(value.getMissing());
    statsResult.setStddev(value.getStddev());
    statsResult.setSumOfSquares((Double) new DirectFieldAccessor(value).getPropertyValue("sumOfSquares"));

    Object mean = value.getMean();
    if (mean instanceof Double) {
        statsResult.setMean((Double) mean);
    }

    Object sum = value.getSum();
    if (sum instanceof Double) {
        statsResult.setSum((Double) sum);
    }

    return statsResult;
}

From source file:com.nridge.ds.solr.SolrResponseBuilder.java

License:Open Source License

private void populateStatistic(QueryResponse aQueryResponse) {
    Object statObject;/*from   ww w .ja  v a2 s  .  c o  m*/
    DataField schemaField;
    FieldStatsInfo fieldStatsInfo;
    String fieldName, fieldTitle, fieldValue;
    Logger appLogger = mAppMgr.getLogger(this, "populateStatistic");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    Map<String, FieldStatsInfo> mapFieldStatsInfo = aQueryResponse.getFieldStatsInfo();
    if (mapFieldStatsInfo != null) {
        mDocument.addRelationship(Solr.RESPONSE_STATISTIC, createStatisticsBag());
        Relationship statisticRelationship = mDocument.getFirstRelationship(Solr.RESPONSE_STATISTIC);
        if (statisticRelationship != null) {
            DataBag statisticsBag = new DataBag(statisticRelationship.getBag());
            statisticsBag.setAssignedFlagAll(false);
            DataTable statisticTable = new DataTable(statisticsBag);
            DataBag resultBag = mBag;

            for (Map.Entry<String, FieldStatsInfo> entry : mapFieldStatsInfo.entrySet()) {
                statisticTable.newRow();
                fieldName = entry.getKey();
                fieldStatsInfo = entry.getValue();
                statisticTable.setValueByName("field_name", fieldName);
                schemaField = resultBag.getFieldByName(fieldName);
                if (schemaField == null)
                    fieldTitle = Field.nameToTitle(fieldName);
                else
                    fieldTitle = schemaField.getTitle();
                statisticTable.setValueByName("field_title", fieldTitle);
                statObject = fieldStatsInfo.getMin();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("min", fieldValue);
                statObject = fieldStatsInfo.getMax();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("max", fieldValue);
                statObject = fieldStatsInfo.getCount();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("count", fieldValue);
                statObject = fieldStatsInfo.getMissing();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("missing", fieldValue);
                statObject = fieldStatsInfo.getSum();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("sum", fieldValue);
                statObject = fieldStatsInfo.getMean();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("mean", fieldValue);
                statObject = fieldStatsInfo.getStddev();
                if (statObject == null)
                    fieldValue = StringUtils.EMPTY;
                else
                    fieldValue = statObject.toString();
                statisticTable.setValueByName("standard_deviation", fieldValue);
                statisticTable.addRow();
            }

            Document facetDocument = new Document(Solr.RESPONSE_STATISTIC, statisticTable);
            statisticRelationship.add(facetDocument);
        }
    }

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:org.apache.nifi.processors.solr.QuerySolr.java

License:Apache License

private static void addStatsFromSolrResponseToJsonWriter(final QueryResponse response, final JsonWriter writer)
        throws IOException {
    writer.beginObject();//from   ww  w.j  av  a 2 s.c  o  m
    writer.name("stats_fields");
    writer.beginObject();
    for (Map.Entry<String, FieldStatsInfo> entry : response.getFieldStatsInfo().entrySet()) {
        FieldStatsInfo fsi = entry.getValue();
        writer.name(entry.getKey());
        writer.beginObject();
        writer.name("min").value(fsi.getMin().toString());
        writer.name("max").value(fsi.getMax().toString());
        writer.name("count").value(fsi.getCount());
        writer.name("missing").value(fsi.getMissing());
        writer.name("sum").value(fsi.getSum().toString());
        writer.name("mean").value(fsi.getMean().toString());
        writer.name("sumOfSquares").value(fsi.getSumOfSquares());
        writer.name("stddev").value(fsi.getStddev());
        writer.endObject();
    }
    writer.endObject();
    writer.endObject();
}

From source file:uk.ac.ebi.phenotype.web.controller.BaselineChartsController.java

License:Apache License

private String generateBaselineChartBoxStyle(String parameterStableId,
        List<FieldStatsInfo> baselinesForParameter) throws SolrServerException, IOException {
    ParameterDTO parameter = impressService.getParameterByStableId(parameterStableId);
    //String procedureName = parameter.getProcedures().iterator().next().getName();
    System.out.println("procedure names=" + parameter.getProcedureNames());

    String yAxisTitle = parameter.getUnitX();
    List<String> xAxisLabels = new ArrayList<>();
    List<List<String>> boxColumns = new ArrayList<>();
    //get the number of decimal places to display
    int decimalPlaces = getDecimalPlacesToDisplay(baselinesForParameter);
    System.out.println("decimalPlaces=" + decimalPlaces);

    Double yMin = new Double(0);
    Double yMax = new Double(0);

    for (FieldStatsInfo baseLine : baselinesForParameter) {
        List<String> boxColumn = new ArrayList<String>();
        xAxisLabels.add("'" + baseLine.getName() + "'");
        if ((Double) baseLine.getMin() < yMin) {
            yMin = (Double) baseLine.getMin();
        }//from  ww  w .  j a  v a2s  .c  o  m
        if ((Double) baseLine.getMax() > yMax) {
            yMax = (Double) baseLine.getMax();
        }
        boxColumn.add(Double
                .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMin(), decimalPlaces)));
        double lower = (double) baseLine.getMean() - (double) baseLine.getStddev();
        boxColumn.add(Double.toString(ChartUtils.getDecimalAdjustedDouble((Double) lower, decimalPlaces)));
        boxColumn.add(Double
                .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMean(), decimalPlaces)));
        double upper = (double) baseLine.getMean() + (double) baseLine.getStddev();
        boxColumn.add(Double.toString(ChartUtils.getDecimalAdjustedDouble((Double) upper, decimalPlaces)));
        boxColumn.add(Double
                .toString(ChartUtils.getDecimalAdjustedDouble((Double) baseLine.getMax(), decimalPlaces)));
        //System.out.println(baseLine.getMin()+ " " +baseLine.getGenotypeEffect()+" "+baseLine.getMax());
        boxColumns.add(boxColumn);
        //System.out.println("boxColumn="+boxColumn);
    }

    List<String> colors = ChartColors.getHighDifferenceColorsRgba(ChartColors.alphaOpaque);

    String seriesData = "{" + " name: 'Observations'," + " data:" + boxColumns
    //                + " ["
    //                + " [760, 801, 848, 895, 965],"
    //                + " [733, 853, 939, 980, 1080],"
    //                + " [714, 762, 817, 870, 918],"
    //                + " [834, 836, 864, 882, 910] ]"
            + "," + " tooltip: {" + " headerFormat: '<em>Experiment No {point.key}</em><br/>'" + " }" + " }";

    String chartString = "$('#baseline-chart-div').highcharts({" + " colors:" + colors
            + ", chart: { type: 'boxplot'},  "
            + " tooltip: { formatter: function () { if(typeof this.point.high === 'undefined')"
            + "{ return '<b>Observation</b><br/>' + this.point.y; } "
            + "else { return '<b>Center: ' + this.key + '</b>" + "<br/>Max: ' + this.point.options.high + '"
            + "<br/>Mean + SD: ' + this.point.options.q3 + '" + "<br/>Mean: ' + this.point.options.median + '"
            + "<br/>Mean - SD: ' + this.point.options.q1 +'" + "<br/>Min: ' + this.point.options.low"
            + "; } } }    ," + " title: {  text: '" + parameter.getName()
            + " WT Variation By Center', useHTML:true } ,  subtitle: {  text: '"
            + parameter.getProcedureNames().get(0) + "' }, " + " credits: { enabled: false },  "
            + " legend: { enabled: false }, " + " xAxis: { categories:  " + xAxisLabels + "," + " labels: { "
            + "           rotation: -45, " + "           align: 'right', " + "           style: { "
            + "              fontSize: '15px'," + "              fontFamily: '\"Roboto\", sans-serif'"
            + "         } " + "     }, " + " }, \n" + " plotOptions: {" + "series:"
            + "{ groupPadding: 0.25, pointPadding: -0.5 }" + "}," + " yAxis: {  " + "max: " + yMax + ",  min: "
            + yMin + "," + " labels: { },title: { text: '" + yAxisTitle + "' }, tickAmount: 5 }, "
            + "\n series: [" + seriesData + "] });";

    return chartString;

}