Maximum number of facets is limited to 100 by default, related Javadoc is wrong


When migrating from Hibernate Search 5.2.1.Final to 5.5.4.Final, we detected an undocumented behavior change in the faceting API (probably introduced with 5.3.0.Final).

The Javadoc of method maxFacetCount in interface states:

maxFacetCount - the maximum number of facets to include in the response. A negative value means that all facets will be included

In fact a negative value means that the number of facets is limited to 100. This is also the default when not using maxFacetCount at all.

This behavior has changed in comparison to 5.2.1.Final, where the number of facets was unlimited by default.

The migration guide (Hibernate Search 5.2.x to 5.3.x) only refers to the changed behavior related to includeZeroCounts, but not regarding maxFacetCount:

I would suggest to adjust the Javadoc and the migration guide. It would also be interesting if there was a specific reason for this behavior change.


  • Hibernate ORM 5.0.9.Final

  • Apache Lucene 5.3.1

  • AdoptOpenJDK 1.8.0-202

  • Microsoft Windows 10

  • Microsoft SQL Server 2016


Yoann Rodière
March 26, 2019, 5:00 PM

Thanks for the report. You are right, that's odd and at the very least the documentation and migration guides should be updated.

I don't know if there is a particular reason, I will have to do some archaeology: this was four years ago

In the meantime, I suppose you can just pass Integer.MAX_VALUE instead of a negative value, that should do what you want.

Bernhard Scholz
March 27, 2019, 10:10 AM

Thanks for the quick response. We have tried using Integer.MAX_VALUE and also Integer.MAX_VALUE - 100, but it did not work out. Both values led to an exception inside the Lucene implementation, where an Object array of size maxFacetCount+1 is created.


Integer.MAX_VALUE - 100

Finally we decided to introduce a customer-specific property for maxFacetCount and set it to 1.000.000 by default.



Yoann Rodière


Bernhard Scholz



Suitable for new contributors


Feedback Requested



Affects versions