Merged searchrep (5.2.1) to 5.2.N (5.2.1)

136808 gjames: SEARCH-339: Adding bucketInfo for intervals with consistent names


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137060 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2017-06-01 11:11:00 +00:00
parent e6db3f683e
commit 14076fbb3b
3 changed files with 43 additions and 36 deletions

View File

@@ -96,8 +96,8 @@ public class SolrJSONResultSet implements ResultSet, JSONResult
private Map<NodeRef, List<Pair<String, List<String>>>> highlighting = new HashMap<>();
private Map<String, List<Pair<String, Integer>>> facetIntervals = new HashMap<String, List<Pair<String, Integer>>>(1);
private Map<String, List<Pair<String, Integer>>> facetIntervals = new HashMap<String, List<Pair<String, Integer>>>(1);
private Map<String,List<Map<String,String>>> facetRanges = new HashMap<String,List<Map<String,String>>>();
private List<GenericFacetResponse> pivotFacets = new ArrayList<>();
@@ -298,32 +298,32 @@ public class SolrJSONResultSet implements ResultSet, JSONResult
String pivotName = (String)it.next();
pivotFacets = buildPivot(facet_pivot, pivotName);
}
}
if(facet_counts.has("facet_ranges"))
{
JSONObject facet_ranges = facet_counts.getJSONObject("facet_ranges");
for(Iterator it = facet_ranges.keys(); it.hasNext();)
{
String fieldName = (String) it.next();
String end = facet_ranges.getJSONObject(fieldName).getString("end");
JSONArray rangeCollection = facet_ranges.getJSONObject(fieldName).getJSONArray("counts");
List<Map<String, String>> buckets = new ArrayList<Map<String, String>>();
for(int i = 0; i < rangeCollection.length(); i+=2)
{
Map<String,String> rangeMap = new HashMap<String,String>(3);
String rangeFrom = rangeCollection.getString(i);
String facetRangeCount = rangeCollection.getString(i+1);
String rangeTo = (i+2 < rangeCollection.length() ? rangeCollection.getString(i+2):end);
String label = rangeFrom + " - " + rangeTo;
rangeMap.put("label", label);
rangeMap.put("count", facetRangeCount);
rangeMap.put("from", rangeFrom);
rangeMap.put("to", rangeTo);
buckets.add(rangeMap);
}
facetRanges.put(fieldName, buckets);
}
}
if(facet_counts.has("facet_ranges"))
{
JSONObject facet_ranges = facet_counts.getJSONObject("facet_ranges");
for(Iterator it = facet_ranges.keys(); it.hasNext();)
{
String fieldName = (String) it.next();
String end = facet_ranges.getJSONObject(fieldName).getString("end");
JSONArray rangeCollection = facet_ranges.getJSONObject(fieldName).getJSONArray("counts");
List<Map<String, String>> buckets = new ArrayList<Map<String, String>>();
for(int i = 0; i < rangeCollection.length(); i+=2)
{
Map<String,String> rangeMap = new HashMap<String,String>(3);
String rangeFrom = rangeCollection.getString(i);
String facetRangeCount = rangeCollection.getString(i+1);
String rangeTo = (i+2 < rangeCollection.length() ? rangeCollection.getString(i+2):end);
String label = rangeFrom + " - " + rangeTo;
rangeMap.put(GenericFacetResponse.LABEL, label);
rangeMap.put(GenericFacetResponse.COUNT, facetRangeCount);
rangeMap.put(GenericFacetResponse.START, rangeFrom);
rangeMap.put(GenericFacetResponse.END, rangeTo);
buckets.add(rangeMap);
}
facetRanges.put(fieldName, buckets);
}
}
}
@@ -722,11 +722,11 @@ public class SolrJSONResultSet implements ResultSet, JSONResult
public boolean getProcessedDenies()
{
return processedDenies;
}
public Map<String,List<Map<String,String>>> getFacetRanges()
{
return facetRanges;
}
}
public Map<String,List<Map<String,String>>> getFacetRanges()
{
return facetRanges;
}
}

View File

@@ -58,14 +58,14 @@ public class GenericBucket
this.facets = facets;
}
public GenericBucket(String label, String filterQuery, Object display, Set<Metric> metrics, List<GenericFacetResponse> facets, Map<String, String> facetInfo)
public GenericBucket(String label, String filterQuery, Object display, Set<Metric> metrics, List<GenericFacetResponse> facets, Map<String, String> bucketInfo)
{
this.label = label;
this.filterQuery = filterQuery;
this.display = display;
this.metrics = metrics;
this.facets = facets;
this.bucketInfo = facetInfo;
this.bucketInfo = bucketInfo;
}
public String getFilterQuery()

View File

@@ -37,6 +37,13 @@ public class GenericFacetResponse
private final String label;
private final List<GenericBucket> buckets;
public static final String LABEL = "label";
public static final String COUNT = "count";
public static final String START = "start";
public static final String END = "end";
public static final String START_INC = "startInclusive";
public static final String END_INC = "endInclusive";
public GenericFacetResponse(FACET_TYPE type, String label, List<GenericBucket> buckets)
{
this.type = type;