you can sort using fields
consider an example:
If you have 5 FACETS and COUNT associated with it. Then you can sort using COUNTS for each field.
It may be applicable to normal / non-facets fields.
public class FacetBean implements Category,Serializable { private String facetName;
Your calling method should look like this
private List<FacetBean> getFacetFieldsbyCount(QueryResponse queryResponse) { List<FacetField> flds = queryResponse.getFacetFields(); List<FacetBean> facetList = new ArrayList<FacetBean>(); FacetBean facet = null; if (flds != null) { for (FacetField fld : flds) { facet = new FacetBean(); facet.setFacetName(fld.getName()); List<Count> counts = fld.getValues(); if (counts != null) { for (Count count : counts) { facet.setFacetCount(count.getCount()); } } facetList.add(facet); } } Collections.sort(facetList,new Comparator<FacetBean>() { public int compare(FacetBean obj1, FacetBean obj2) { if(obj1.getFacetCount() > obj2.getFacetCount()) { return (int)obj1.getFacetCount(); } else { return (int)obj2.getFacetCount(); } } }); return facetList; }
In the same URL, they mentioned something like.
sort β ex: For example, sorting = popularity desc will sort the groups according to the highest popularity doc
group.sort β you can apply your field here.
Hope this helps.
source share