[
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-776?pag...
]
Adrian Meredith commented on HSEARCH-776:
-----------------------------------------
My suspicions are confirmed, looking at the source,
{code}
private List<Facet> createSortedFacetList(FacetCounter counter, FacetingRequestImpl
request) {
List<Facet> facetList = newArrayList();
int includedFacetCount = 0;
for ( Map.Entry<String, Integer> countEntry : counter.getCounts().entrySet() ) {
Facet facet = request.createFacet( countEntry.getKey(), countEntry.getValue() );
if ( !request.hasZeroCountsIncluded() && facet.getCount() == 0 ) {
continue;
}
if ( facetRequest.getMaxNumberOfFacets() > 0 && includedFacetCount ==
facetRequest.getMaxNumberOfFacets() ) {
break;
}
facetList.add( facet );
includedFacetCount++;
}
Collections.sort( facetList, new FacetComparator( request.getSort() ) );
return facetList;
}
{code}
You can clearly see that it restricts the the items in the list THEN sorts it. causing
only the first unsorted facets to be returned. Sorting first should resolved this bug,
will confirm myself if i can
maxFacetCount returns incorrect results when ordering a faceted
query
---------------------------------------------------------------------
Key: HSEARCH-776
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-776
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.4.0.Final
Environment: hibernate 3.6.4, hibernate search 3.4
Reporter: Adrian Meredith
Priority: Critical
When putting a restriction on facets such as
{code}
FacetingRequest fr =
qb.facet().name("name").onField("someField").discrete().orderedBy(FacetSortOrder.COUNT_DESC).maxFacetCount(10).includeZeroCounts(false).createFacetingRequest();
{code}
I would expect the facets with the top 10 results to be returned which appears to be true
but it seems some are randomly missing (like the 10 are somehow spread across all results
as opposed to the top ten). Removing the max restriction and only returning the first ten
entries shows the correct results.
for example
{code}
QueryBuilder qb =
ftEm.getSearchFactory().buildQueryBuilder().forEntity(WebResult.class).get();
FacetManager fm = query.getFacetManager()
FacetingRequest fr =
qb.facet().name("name").onField("someField.id").discrete().orderedBy(FacetSortOrder.COUNT_DESC).includeZeroCounts(false).createFacetingRequest();
fm.enableFaceting(fr);
fm.getFacets("name").subList(0, endIndex);
{code}
The two code examples should return the exact same thing but the don't. The below
code is my workaround but as you can imaging this could potentially take a dangerous
amount of memory due to it effectively loading the entire index.
My WebResult class has OneToOne relations to various other objects (e.g. country)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira