mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-10-01 14:41:19 +00:00
SEARCH-2126: Address formatting issues.
This commit is contained in:
@@ -610,47 +610,41 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Facet SOLR Queries are omitting facet results with count equals to 0 as general rule.
|
* Facet SOLR Queries are omitting facet results with count equals to 0 as general rule.
|
||||||
* SOLR Queries executed on a Shard environment, don't include these results but the same
|
* SOLR Queries executed on a Shard environment, don't include these results but the same
|
||||||
* query executed on a single server environment are adding these elements to the response.
|
* query executed on a single server environment are adding these elements to the response.
|
||||||
*
|
* This method removes every facet query having count equals to 0 to provide the same
|
||||||
* This method removes every facet query having count equals to 0 to provide the same
|
* behaviour in both cases.
|
||||||
* behaviour in both cases.
|
*
|
||||||
*
|
* A query like the following, will return only Facet Queries having elements:
|
||||||
* A query like the following, will return only Facet Queries having elements:
|
* "facetQueries" : [
|
||||||
*
|
* { "query" : "content.size:[0 TO 102400]", "label" : "small"},
|
||||||
* "facetQueries" : [
|
* { "query" : "content.size:[102400 TO 1048576]", "label" : "medium"},
|
||||||
* { "query" : "content.size:[0 TO 102400]", "label" : "small"},
|
* { "query" : "content.size:[1048576 TO 16777216]", "label" : "large"}
|
||||||
* { "query" : "content.size:[102400 TO 1048576]", "label" : "medium"},
|
* ]
|
||||||
* { "query" : "content.size:[1048576 TO 16777216]", "label" : "large"}
|
*
|
||||||
* ]
|
* For instance, if there are only results with "small" key, the result will be:
|
||||||
*
|
* "facetQueries": [
|
||||||
* For instance, if there are only results with "small" key, the result will be:
|
* {
|
||||||
*
|
* "label": "small",
|
||||||
* "facetQueries": [
|
* "filterQuery": "content.size:[0 TO 102400]",
|
||||||
* {
|
* "count": 5
|
||||||
* "label": "small",
|
* }
|
||||||
* "filterQuery": "content.size:[0 TO 102400]",
|
* ]
|
||||||
* "count": 5
|
*
|
||||||
* }
|
*/
|
||||||
*
|
public static final String FACET_COUNTS_KEY = "facet_counts";
|
||||||
* @param rsp
|
public static final String FACET_QUERIES_KEY = "facet_queries";
|
||||||
*/
|
public static final String FACET_CONTEXT_KEY = "_facet.context";
|
||||||
public static final String FACET_COUNTS_KEY = "facet_counts";
|
|
||||||
public static final String FACET_QUERIES_KEY = "facet_queries";
|
@SuppressWarnings("unchecked")
|
||||||
public static final String FACET_CONTEXT_KEY = "_facet.context";
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private void removeFacetQueriesWithCountZero(SolrQueryResponse rsp)
|
private void removeFacetQueriesWithCountZero(SolrQueryResponse rsp)
|
||||||
{
|
{
|
||||||
|
|
||||||
NamedList<Object> facetCounts = (NamedList<Object>) rsp.getValues().get(FACET_COUNTS_KEY);
|
NamedList<Object> facetCounts = (NamedList<Object>) rsp.getValues().get(FACET_COUNTS_KEY);
|
||||||
|
|
||||||
if (facetCounts != null)
|
if (facetCounts != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
NamedList<Object> facetQueries = (NamedList<Object>) facetCounts.get(FACET_QUERIES_KEY);
|
NamedList<Object> facetQueries = (NamedList<Object>) facetCounts.get(FACET_QUERIES_KEY);
|
||||||
|
|
||||||
if (facetQueries != null)
|
if (facetQueries != null)
|
||||||
{
|
{
|
||||||
List<String> keyCountsToRemove = new ArrayList<>();
|
List<String> keyCountsToRemove = new ArrayList<>();
|
||||||
@@ -666,14 +660,15 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
|
|||||||
{
|
{
|
||||||
keyCountsToRemove.forEach(key -> facetQueries.remove(key));
|
keyCountsToRemove.forEach(key -> facetQueries.remove(key));
|
||||||
|
|
||||||
((NamedList<Object>)rsp.getValues().get(FACET_COUNTS_KEY)).remove(FACET_QUERIES_KEY);
|
((NamedList<Object>) rsp.getValues().get(FACET_COUNTS_KEY)).remove(FACET_QUERIES_KEY);
|
||||||
((NamedList<Object>)rsp.getValues().get(FACET_COUNTS_KEY)).add(FACET_QUERIES_KEY, facetQueries);
|
((NamedList<Object>) rsp.getValues().get(FACET_COUNTS_KEY)).add(FACET_QUERIES_KEY,
|
||||||
|
facetQueries);
|
||||||
|
|
||||||
BasicResultContext result = (BasicResultContext) rsp.getResponse();
|
BasicResultContext result = (BasicResultContext) rsp.getResponse();
|
||||||
FacetContext facetContext = (FacetContext) result.getRequest().getContext().get(FACET_CONTEXT_KEY);
|
FacetContext facetContext = (FacetContext) result.getRequest().getContext()
|
||||||
facetContext.getAllQueryFacets().removeIf(queryFacet ->
|
.get(FACET_CONTEXT_KEY);
|
||||||
keyCountsToRemove.contains(queryFacet.getKey())
|
facetContext.getAllQueryFacets()
|
||||||
);
|
.removeIf(queryFacet -> keyCountsToRemove.contains(queryFacet.getKey()));
|
||||||
result.getRequest().getContext().put(FACET_CONTEXT_KEY, facetContext);
|
result.getRequest().getContext().put(FACET_CONTEXT_KEY, facetContext);
|
||||||
|
|
||||||
log.debug("In SOLR query '" + result.getRequest() + "', Facet Queries results having labels "
|
log.debug("In SOLR query '" + result.getRequest() + "', Facet Queries results having labels "
|
||||||
@@ -681,7 +676,7 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////// SolrInfoMBeans methods //////////////////////
|
// ////////////////////// SolrInfoMBeans methods //////////////////////
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user