From 5be4c12cb93b51590dee1c83360447c16729a232 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 5 Jun 2019 20:22:32 +0000
Subject: [PATCH] Bug 22924: Make elasticsearch honour FacetMaxCount system
 preference

We have a line in QueryBuilder to respect the preference if a facet is expanded, it seems
we forgot to pass the option to the querybuilder however

To test:
1 - Enable Elasticsearch
2 - Set FacetMaxCount to 20
3 - Search in ES for '*' or something with a lot of results
4 - Expand some facets, note you get no more than 10 for any facet
5 - Apply patch
6 - Search again
7 - Expand facets, note they now go up to 20
8 - Try with various values of FacetMaxCount

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
---
 catalogue/search.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/catalogue/search.pl b/catalogue/search.pl
index 514c4a9..bc36133 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -465,6 +465,7 @@ my $expanded_facet = $params->{'expand'};
 my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
 
 my $build_params;
+$build_params->{expanded_facet} = $expanded_facet;
 unless ( $cgi->param('advsearch') ) {
     $build_params->{weighted_fields} = 1;
 }
-- 
2.7.4