This repository was archived by the owner on Jan 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
main/java/com/algolia/search/saas
test/java/com/algolia/search/saas Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -813,6 +813,19 @@ public Polygon(Polygon other) {
813813 }
814814 }
815815
816+ private static final String KEY_MAX_FACET_HITS = "maxFacetHits" ;
817+
818+ /**
819+ * Limit the number of facet values returned for each facet.
820+ */
821+ public @ NonNull Query setMaxFacetHits (Integer n ) {
822+ return set (KEY_MAX_FACET_HITS , n );
823+ }
824+
825+ public Integer getMaxFacetHits () {
826+ return parseInt (get (KEY_MAX_FACET_HITS ));
827+ }
828+
816829 private static final String KEY_MAX_VALUES_PER_FACET = "maxValuesPerFacet" ;
817830
818831 /**
Original file line number Diff line number Diff line change @@ -644,6 +644,16 @@ public void removeStopWordsInvalidClass() throws Exception {
644644 fail ("setRemoveStopWords should throw when its parameter is neither Boolean nor String." );
645645 }
646646
647+ @ Test
648+ public void maxFacetHits () {
649+ Query query = new Query ();
650+ assertNull (query .getMaxFacetHits ());
651+ query .setMaxFacetHits (456 );
652+ assertEquals (Integer .valueOf (456 ), query .getMaxFacetHits ());
653+ assertEquals ("456" , query .get ("maxFacetHits" ));
654+ assertEquals (query .getMaxFacetHits (), Query .parse (query .build ()).getMaxFacetHits ());
655+ }
656+
647657 @ Test
648658 public void maxValuesPerFacet () {
649659 Query query = new Query ();
You can’t perform that action at this time.
0 commit comments