List of usage examples for org.apache.solr.client.solrj.response PivotField getField
public String getField()
From source file:com.frank.search.solr.core.ResultHelper.java
License:Apache License
private static List<FacetPivotFieldEntry> convertPivotResult(List<PivotField> pivotResult) { if (CollectionUtils.isEmpty(pivotResult)) { return Collections.emptyList(); }/*w w w . j a v a 2 s . c o m*/ ArrayList<FacetPivotFieldEntry> pivotFieldEntries = new ArrayList<FacetPivotFieldEntry>(); for (PivotField pivotField : pivotResult) { SimpleFacetPivotEntry pivotFieldEntry = new SimpleFacetPivotEntry( new SimpleField(pivotField.getField()), String.valueOf(pivotField.getValue()), pivotField.getCount()); List<PivotField> pivot = pivotField.getPivot(); if (pivot != null) { pivotFieldEntry.setPivot(convertPivotResult(pivot)); } pivotFieldEntries.add(pivotFieldEntry); } return pivotFieldEntries; }
From source file:com.nridge.ds.solr.SolrResponseBuilder.java
License:Open Source License
private int populateFacetPivot(DataTable aTable, String[] aFacetNames, int aRowId, int aParentId, PivotField aPivotField) { Object facetValue;/* ww w. j a v a 2s.co m*/ FieldRow fieldRow; String fieldName, facetName, facetNameCount; Logger appLogger = mAppMgr.getLogger(this, "populateFacetPivot"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if (aPivotField != null) { fieldName = aPivotField.getField(); facetValue = aPivotField.getValue(); if (facetValue == null) facetNameCount = String.format("Unassigned (%s)", aPivotField.getCount()); else { facetName = aPivotField.getValue().toString(); facetNameCount = String.format("%s (%s)", facetName, aPivotField.getCount()); } ArrayList<String> facetValues = null; if (StringUtils.equals(fieldName, aFacetNames[0])) aParentId = 0; else { int rowCount = aTable.rowCount(); if (rowCount > 0) { fieldRow = aTable.getRow(rowCount - 1); facetValues = aTable.getValuesByName(fieldRow, fieldName); if (facetValues != null) { if (facetValues.size() == 0) facetValues = null; else facetValues.add(facetNameCount); } } } if (facetValues == null) { fieldRow = aTable.newRow(); aTable.setValueByName(fieldRow, "id", aRowId + 1); aTable.setValueByName(fieldRow, "parent_id", aParentId); facetValues = aTable.getValuesByName(fieldRow, fieldName); if (facetValues != null) { facetValues.add(facetNameCount); if (facetValues.size() == 1) { aTable.addRow(fieldRow); aRowId = aTable.rowCount(); aParentId = aRowId; } } } if (aPivotField.getPivot() != null) { for (PivotField pivotField : aPivotField.getPivot()) aRowId = populateFacetPivot(aTable, aFacetNames, aRowId, aParentId, pivotField); } } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); return aRowId; }
From source file:fr.cnes.sitools.metacatalogue.representation.GeoJsonMDEORepresentation.java
License:Open Source License
private void writeFacetPivots(JsonGenerator jGenerator, List<PivotField> pivotFields) throws JsonGenerationException, IOException { if (pivotFields == null) { return;/* w w w.j a va 2 s .co m*/ } jGenerator.writeStartArray(); for (PivotField field : pivotFields) { jGenerator.writeStartObject(); jGenerator.writeStringField("field", field.getField()); jGenerator.writeStringField("value", getValue(field.getField(), field.getValue().toString())); jGenerator.writeNumberField("count", field.getCount()); if (field.getPivot() != null) { jGenerator.writeFieldName("pivot"); writeFacetPivots(jGenerator, field.getPivot()); } jGenerator.writeEndObject(); } jGenerator.writeEndArray(); }
From source file:org.apache.drill.exec.store.solr.SolrRecordReader.java
License:Apache License
private int processFacetPivotResponse(List<PivotField> facetPivots) { SolrFacetPivot2ResultSet oSolrFacetPivot2ResultSet = new SolrFacetPivot2ResultSet(); oSolrFacetPivot2ResultSet.build(facetPivots); int resultSeek = 0; int leafNodesSeek = 0; while (!oSolrFacetPivot2ResultSet.isEmpty()) { SolrFacetPivotRecord oSolrFacetPivotRecord = (SolrFacetPivotRecord) oSolrFacetPivot2ResultSet.pop(); PivotField pivotField = oSolrFacetPivotRecord.getPivotField(); String fieldName = pivotField.getField(); Object fieldValue = pivotField.getValue(); ValueVector vv = vectors.get(fieldName); if (oSolrFacetPivotRecord.getPivotSize() == 0) { Map<String, FieldStatsInfo> fieldStatsInfo = pivotField.getFieldStatsInfo(); processRecord(vv, fieldValue, leafNodesSeek); int statsCounter = 0; if (isCountOnlyQuery()) { processCountQuery(vectors.get(String.valueOf(statsCounter)), Long.valueOf(pivotField.getCount()), statsCounter, leafNodesSeek); statsCounter++;//from w ww .j ava 2 s . c o m } else { for (SolrAggrParam solrAggrParam : solrAggrParams) { FieldStatsInfo fieldStats = fieldStatsInfo.get(getSolrField(solrAggrParam.getFieldName(), solrScanSpec.getCvSchema().getUniqueKey())); String functionName = solrAggrParam.getFunctionName(); if (fieldStats != null) { processStatsRecord(fieldStats, functionName, statsCounter, leafNodesSeek, solrScanSpec.isGroup()); statsCounter++; if (statsCounter == solrScanSpec.getProjectFieldNames().size()) { break; } } } } leafNodesSeek++; } else { int start = (leafNodesSeek == oSolrFacetPivotRecord.getPivotSize()) ? 0 : Math.abs((leafNodesSeek - oSolrFacetPivotRecord.getPivotSize())); int end = (start == 0) ? leafNodesSeek : (start + oSolrFacetPivotRecord.getPivotSize()); SolrRecordReader.logger.info("Start is : " + start + " End is : " + end); for (int i = start; i < end; i++) { processRecord(vv, fieldValue, i); } resultSeek += oSolrFacetPivotRecord.getPivotSize(); } } return (resultSeek == 0) ? leafNodesSeek : resultSeek; }
From source file:org.mousephenotype.cda.solr.service.BasicService.java
License:Apache License
/** * Recursive method to fill a map with multiple combination of pivot fields. * Each pivot level can have multiple children. Hence, each level should * pass back to the caller a list of all possible combination * //from w w w. j ava2s . co m * @param pivotLevel */ protected List<Map<String, String>> getLeveledFacetPivotValue(PivotField pivotLevel, PivotField parentPivot, boolean keepCount) { List<Map<String, String>> results = new ArrayList<Map<String, String>>(); List<PivotField> pivotResult = pivotLevel.getPivot(); if (pivotResult != null) { for (int i = 0; i < pivotResult.size(); i++) { List<Map<String, String>> lmap = getLeveledFacetPivotValue(pivotResult.get(i), pivotLevel, keepCount); // add the parent pivot if (parentPivot != null) { for (Map<String, String> map : lmap) { map.put(parentPivot.getField(), parentPivot.getValue().toString()); if (keepCount) map.put(parentPivot.getField() + "_count", new Integer(parentPivot.getCount()).toString()); } } results.addAll(lmap); } } else { // It is important to test the state of the parentPivot here since Solr7 // does not return an empty pivot list if there is no associated data // // The Solr 4 query response format was: // {field=procedure_stable_id,value=GMC_900_001,count=26,pivot=[]} // // The Solr 7 query response format is: // {field=procedure_stable_id,value=GMC_900_001,count=26} // if (parentPivot != null) { Map<String, String> map = new HashMap<String, String>(); map.put(pivotLevel.getField(), pivotLevel.getValue().toString()); if (keepCount) map.put(pivotLevel.getField() + "_count", new Integer(pivotLevel.getCount()).toString()); // add the parent pivot map.put(parentPivot.getField(), parentPivot.getValue().toString()); if (keepCount) map.put(parentPivot.getField() + "_count", new Integer(parentPivot.getCount()).toString()); results.add(map); } } // return results; }
From source file:org.mousephenotype.cda.solr.service.ObservationService.java
License:Apache License
private Set<String> getParametersForChartFromPivot(PivotField pivot, String urlParams, Set<String> set) { if (pivot != null) { urlParams += pivot.getField() + "=" + pivot.getValue().toString() + "&"; if (pivot.getPivot() != null) { for (PivotField p : pivot.getPivot()) { getParametersForChartFromPivot(p, urlParams, set); }//w ww .j a v a 2s .c o m } else { set.add(urlParams); } } return set; }
From source file:org.mousephenotype.cda.solr.service.StatisticalResultService.java
License:Apache License
private Set<String> getParametersForChartFromPivot(PivotField pivot, String urlParams, Set<String> set) { if (pivot != null) { if (pivot.getValue().toString().length() > 0) {//if the value is not set don't add an empty string parameter as this will then fail with the metadata_group being set to empty string!! urlParams += pivot.getField() + "=" + pivot.getValue().toString() + "&"; }//w ww .j a va 2 s. co m if (pivot.getPivot() != null) { for (PivotField p : pivot.getPivot()) { getParametersForChartFromPivot(p, urlParams, set); } } else { set.add(urlParams); } } return set; }
From source file:uk.ac.ebi.phenotype.service.BasicService.java
License:Apache License
/** * Recursive method to fill a map with multiple combination of pivot fields. * Each pivot level can have multiple children. Hence, each level should * pass back to the caller a list of all possible combination * //from w ww .j a v a2 s.c o m * @param pivotLevel * @param map */ protected List<Map<String, String>> getLeveledFacetPivotValue(PivotField pivotLevel, PivotField parentPivot, boolean keepCount) { List<Map<String, String>> results = new ArrayList<Map<String, String>>(); List<PivotField> pivotResult = pivotLevel.getPivot(); if (pivotResult != null) { for (int i = 0; i < pivotResult.size(); i++) { List<Map<String, String>> lmap = getLeveledFacetPivotValue(pivotResult.get(i), pivotLevel, keepCount); // add the parent pivot if (parentPivot != null) { for (Map<String, String> map : lmap) { map.put(parentPivot.getField(), parentPivot.getValue().toString()); if (keepCount) map.put(parentPivot.getField() + "_count", new Integer(parentPivot.getCount()).toString()); } } results.addAll(lmap); } } else { Map<String, String> map = new HashMap<String, String>(); map.put(pivotLevel.getField(), pivotLevel.getValue().toString()); if (keepCount) map.put(pivotLevel.getField() + "_count", new Integer(pivotLevel.getCount()).toString()); // add the parent pivot if (parentPivot != null) { map.put(parentPivot.getField(), parentPivot.getValue().toString()); if (keepCount) map.put(parentPivot.getField() + "_count", new Integer(parentPivot.getCount()).toString()); } results.add(map); } // return results; }