From adf245bef206468368de81759bac6a8640ce70d4 Mon Sep 17 00:00:00 2001 From: Jon Cooper Date: Mon, 28 Oct 2024 12:40:41 +0000 Subject: [PATCH] Facet queries now have no limit EMC-36 --- .../java/uk/ac/ceh/gateway/catalogue/search/SearchQuery.java | 1 + .../java/uk/ac/ceh/gateway/catalogue/search/SearchQueryTest.java | 1 + 2 files changed, 2 insertions(+) diff --git a/java/src/main/java/uk/ac/ceh/gateway/catalogue/search/SearchQuery.java b/java/src/main/java/uk/ac/ceh/gateway/catalogue/search/SearchQuery.java index 942e16ddc..121a60621 100644 --- a/java/src/main/java/uk/ac/ceh/gateway/catalogue/search/SearchQuery.java +++ b/java/src/main/java/uk/ac/ceh/gateway/catalogue/search/SearchQuery.java @@ -329,6 +329,7 @@ private void setFacetFilters(SolrQuery query){ private void setFacetFields(SolrQuery query){ query.setFacet(true); query.setFacetMinCount(1); + query.setFacetLimit(-1); query.setFacetSort("index"); facets.forEach((facet) -> query.addFacetField(facet.getFieldName()) diff --git a/java/src/test/java/uk/ac/ceh/gateway/catalogue/search/SearchQueryTest.java b/java/src/test/java/uk/ac/ceh/gateway/catalogue/search/SearchQueryTest.java index d294a3968..a02f9e7ef 100644 --- a/java/src/test/java/uk/ac/ceh/gateway/catalogue/search/SearchQueryTest.java +++ b/java/src/test/java/uk/ac/ceh/gateway/catalogue/search/SearchQueryTest.java @@ -218,6 +218,7 @@ public void buildQueryWithNoExtraParameters() { assertThat(solrQuery.getRows(), is(equalTo(DEFAULT_ROWS))); assertThat(solrQuery.getFacetMinCount(), is(equalTo(1))); assertThat(solrQuery.getSorts().get(0).getItem().substring(0, 6), is(equalTo("random"))); + assertThat("Facets should have a default limit of -1 (ie infinite)", solrQuery.getFacetLimit(), equalTo(-1)); } @Test