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

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

Introduction

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

Prototype

public String getName() 

Source Link

Usage

From source file:au.org.ala.biocache.dao.SearchDAOImpl.java

License:Open Source License

/**
 * @see au.org.ala.biocache.dao.SearchDAO#searchStat
 *///from ww  w  .  ja  v a 2s .  co  m
public List<FieldStatsItem> searchStat(SpatialSearchRequestParams searchParams, String field, String facet)
        throws Exception {
    searchParams.setFacets(new String[] {});

    queryFormatUtils.formatSearchQuery(searchParams);
    String queryString = searchParams.getFormattedQuery();

    if (facet != null)
        searchParams.setFacet(true);

    //get facet group counts
    SolrQuery query = initSolrQuery(searchParams, false, null);
    query.setQuery(queryString);
    query.setFields(null);
    //query.setFacetLimit(-1);

    //stats parameters
    query.add("stats", "true");
    if (facet != null)
        query.add("stats.facet", facet);
    query.add("stats.field", field);

    query.setRows(0);
    searchParams.setPageSize(0);
    QueryResponse response = runSolrQuery(query, searchParams);

    List<FieldStatsItem> output = new ArrayList();
    if (facet != null && response.getFieldStatsInfo().size() > 0) {
        for (FieldStatsInfo f : response.getFieldStatsInfo().values().iterator().next().getFacets().values()
                .iterator().next()) {
            FieldStatsItem item = new FieldStatsItem(f);
            if (f.getName() == null) {
                item.setFq("-" + facet + ":*");
            } else {
                item.setFq(facet + ":\"" + f.getName() + "\"");
            }
            item.setLabel(f.getName());
            output.add(item);
        }
    } else {
        if (response.getFieldStatsInfo().size() > 0) {
            output.add(new FieldStatsItem(response.getFieldStatsInfo().values().iterator().next()));
        }
    }

    return output;
}

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

License:Apache License

private static Map<String, Map<String, StatsResult>> convertFieldStatsInfoToStatsResultMap(
        Map<String, List<FieldStatsInfo>> statsInfo) {

    Map<String, Map<String, StatsResult>> result = new LinkedHashMap<String, Map<String, StatsResult>>();

    for (Entry<String, List<FieldStatsInfo>> entry : statsInfo.entrySet()) {
        Map<String, StatsResult> facetStatsValues = new LinkedHashMap<String, StatsResult>();

        for (FieldStatsInfo fieldStatsInfo : entry.getValue()) {

            SimpleStatsResult statsResult = populateStatsResultWithFieldStatsInfo(new SimpleStatsResult(),
                    fieldStatsInfo);//from  w ww  .  ja va 2 s.  c om
            facetStatsValues.put(fieldStatsInfo.getName(), statsResult);
        }

        result.put(entry.getKey(), facetStatsValues);
    }

    return result;
}

From source file:org.apache.drill.exec.store.solr.SolrRecordReader.java

License:Apache License

private int processStatsFieldResponse(Map<String, FieldStatsInfo> fieldStatsInfoMap, boolean isGroup,
        String uniqueKey) {// www  .  ja  va  2s .com
    int counter = 0;
    int statsCounter = 0;
    Object fieldValue = null;
    if (isGroup) {
        for (SolrAggrParam solrAggrParam : solrAggrParams) {
            String statsKey = solrAggrParam.getFieldName();
            String functionName = solrAggrParam.getFunctionName();
            FieldStatsInfo fieldStats = fieldStatsInfoMap.get(getSolrField(statsKey, uniqueKey));
            Map<String, List<FieldStatsInfo>> statsFacet = fieldStats.getFacets();

            for (String groupKey : statsFacet.keySet()) {
                counter = 0;
                List<FieldStatsInfo> facetStats = statsFacet.get(groupKey);
                ValueVector vv = vectors.get(groupKey);
                if (vv != null) {
                    for (FieldStatsInfo fieldStatsInfo : facetStats) {
                        fieldValue = fieldStatsInfo.getName();
                        processRecord(vv, fieldValue, counter);
                        processStatsRecord(fieldStatsInfo, functionName, statsCounter, counter, isGroup);
                        counter++; // actual record counter
                    }
                }
            }

            statsCounter++;
        }
    } else {
        for (SolrAggrParam solrAggrParam : solrAggrParams) {
            FieldStatsInfo fieldStats = fieldStatsInfoMap
                    .get(getSolrField(solrAggrParam.getFieldName(), uniqueKey));
            String functionName = solrAggrParam.getFunctionName();

            if (fieldStats != null) {
                processStatsRecord(fieldStats, functionName, statsCounter, counter, isGroup);
                statsCounter++;

                if (statsCounter == solrScanSpec.getProjectFieldNames().size()) {
                    break;
                }
            }
        }

        counter++; // actual record counter
    }
    return counter;
}

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();
        }/*  w  ww  .  j av a 2s  .  com*/
        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;

}

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

License:Apache License

private String generateBaselineChartBarStyle(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<String> means = new ArrayList();
    for (FieldStatsInfo baseLine : baselinesForParameter) {
        xAxisLabels.add("'" + baseLine.getName() + "'");
        means.add(baseLine.getMean().toString());
        System.out.println(baseLine.getMin() + " " + baseLine.getMax() + " " + baseLine.getMean());
    }/*from www .j  a va  2s .  co  m*/
    //[-9.7, 9.4],
    int decimalPlaces = ChartUtils.getDecimalPlacesFromStrings(means);
    System.out.println("decimalPlaces=" + decimalPlaces);
    List<Float> meanFloats = getDecimalAdjustedValues(means, decimalPlaces);

    List<String> minAndMax = new ArrayList<>();
    for (FieldStatsInfo baseLine : baselinesForParameter) {
        minAndMax.add(
                "[" + ChartUtils.getDecimalAdjustedFloat(new Float(baseLine.getMin().toString()), decimalPlaces)
                        + "," + new Float(baseLine.getMax().toString()) + "]");
    }
    String minAndMaxData = StringUtils.join(minAndMax, ",");
    System.out.println("minAndMaxData=" + minAndMaxData);
    System.out.println("means=" + means);
    List<String> colors = ChartColors.getHighDifferenceColorsRgba(ChartColors.alphaOpaque);
    String chartString = "$('#baseline-chart-div').highcharts({" + " colors:" + colors + ", " +

            " chart: {  " + " type: 'columnrange',  inverted: false },  title: { text: '" + parameter.getName()
            + " WT Variation By Center' }, subtitle: {  text: '" + parameter.getProcedureNames().get(0) + "' },"
            + " plotOptions: {   series: {  states: { hover: { enabled: false  }   }  } }," + "  xAxis: {"
            + " categories: " + xAxisLabels + "}," + "  yAxis: {" + " title: { text: '" + yAxisTitle + "' }"
            + "  }," + "  tooltip: {" + "  valueSuffix: '" + yAxisTitle + "' }," + "  plotOptions: {"
            + " columnrange: { " + "dataLabels: {"
            + "  enabled: false,   formatter: function () { return this.y + '" + yAxisTitle + "'; }" + "   }"
            + "  }" + "}, legend: { enabled: false  }, tooltip: { enabled: false }," + " series: "
            + "[ {  name: '" + parameter.getName() + yAxisTitle + "',  data: [  " + minAndMaxData + " ] },"
            + " {  type: 'scatter', name: 'Observations', data: " + meanFloats + ", marker: { radius: 4 } }]"
            + "  });";

    System.out.println("chartString=" + chartString);
    return chartString;

}