// field
// The faceting will automatically be
// limited to
// the 10 years in our span due to our
// filterquery
queryArgs.addFacetField(new DiscoverFacetField(
facet.getIndexFieldName(), facet.getType(),
10, facet.getSortOrder()));
}
else
{
java.util.List<String> facetQueries = new ArrayList<String>();
// Create facet queries but limit then to 11
// (11
// == when we need to show a show more url)
for (int year = topYear; year > oldestYear
&& (facetQueries.size() < 11); year -= gap)
{
// Add a filter to remove the last year
// only
// if we aren't the last year
int bottomYear = year - gap;
// Make sure we don't go below our last
// year
// found
if (bottomYear < oldestYear)
{
bottomYear = oldestYear;
}
// Also make sure we don't go above our
// newest year
int currentTop = year;
if ((year == topYear))
{
currentTop = newestYear;
}
else
{
// We need to do -1 on this one to
// get a
// better result
currentTop--;
}
facetQueries.add(dateFacet + ":[" + bottomYear
+ " TO " + currentTop + "]");
}
for (String facetQuery : facetQueries)
{
queryArgs.addFacetQuery(facetQuery);
}
}
}
catch (Exception e)
{
log.error(
LogManager
.getHeader(
context,
"Error in discovery while setting up date facet range",
"date facet: " + dateFacet), e);
}
}
else
{
int facetLimit = type==TYPE_FACETS?facet.getFacetLimit():-1;
int facetPage = UIUtil.getIntParameter(request,
facet.getIndexFieldName() + "_page");
if (facetPage < 0)
{
facetPage = 0;
}
// at most all the user filters belong to this facet
int alreadySelected = userFilters.size();
// Add one to our facet limit to make sure that if
// we
// have more then the shown facets that we show our
// show
// more url
// add the already selected facet so to have a full
// top list
// if possible
int limit = 0;
if (type==TYPE_FACETS){
limit = facetLimit + 1 + alreadySelected;
}
else
limit = facetLimit;
queryArgs.addFacetField(new DiscoverFacetField(facet
.getIndexFieldName(),
DiscoveryConfigurationParameters.TYPE_TEXT,
limit, facet
.getSortOrder(), facetPage * facetLimit));
}