From bec1c31f8e811f6fd4f3331c16310c9cf8c8cffd Mon Sep 17 00:00:00 2001 From: Cliff Ingham Date: Fri, 2 Jul 2021 09:57:40 -0400 Subject: [PATCH] Fixed: search map now uses Solarium Updates #381 --- crm/blocks/html/tickets/searchResultsMap.inc | 16 ++++++++-------- crm/public/js/tickets/searchResultsMap.js | 3 +-- .../Application/Controllers/SolrController.php | 7 +++---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/crm/blocks/html/tickets/searchResultsMap.inc b/crm/blocks/html/tickets/searchResultsMap.inc index 60e78c83..e9372cd5 100644 --- a/crm/blocks/html/tickets/searchResultsMap.inc +++ b/crm/blocks/html/tickets/searchResultsMap.inc @@ -2,15 +2,15 @@ /** * Displays a map of the search results * - * @copyright 2013-2020 City of Bloomington, Indiana + * @copyright 2013-2021 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE - * @param Apache_Solr_Response $this->solrObject + * @param \Solarium\QueryType\Select\Result\Result $this->result */ use Blossom\Classes\Block; use Blossom\Classes\Url; $this->_include('tickets/partials/searchResultsFormatButtons.inc'); -$c = $this->solrObject->response->numFound; +$c = $this->result->getNumFound(); ?>
@@ -38,10 +38,10 @@ $c = $this->solrObject->response->numFound; } $zoom = isset($_GET['zoom']) ? (int)$_GET['zoom'] : 12; - $solr_params = isset($this->solrObject->responseHeader->params) - ? json_encode($this->solrObject->responseHeader->params) - : '{}'; - + $query = $this->result->getQuery()->getOptions(); + $fq = []; + foreach ($query['filterquery'] as $q) { $fq[] = $q['query']; } + $params = json_encode(['query'=>$query['query'], 'fq'=>$fq ]); echo "
@@ -49,7 +49,7 @@ $c = $this->solrObject->response->numFound; var CENTER_LATITUDE = $centerLatitude; var CENTER_LONGITUDE = $centerLongitude; var ZOOM = $zoom; - var SOLR_PARAMS = $solr_params; + var SOLR_PARAMS = $params; "; diff --git a/crm/public/js/tickets/searchResultsMap.js b/crm/public/js/tickets/searchResultsMap.js index e035d3c5..a8c38944 100644 --- a/crm/public/js/tickets/searchResultsMap.js +++ b/crm/public/js/tickets/searchResultsMap.js @@ -64,8 +64,7 @@ google.maps.event.addDomListener(window, 'load', function () { }, getSolrBaseUrl = function (coordinates) { var url = CRM.BASE_URI + '/solr?'; - url += SOLR_PARAMS.q ? 'q=' + SOLR_PARAMS.q : 'q=*.*'; - url += SOLR_PARAMS.sort ? '&sort=' + SOLR_PARAMS.sort : ''; + url += SOLR_PARAMS.q ? 'q=' + SOLR_PARAMS.q : 'q=*:*'; url += getFqParameters() + '&fq=coordinates:' + coordinates; url += '&wt=json&json.nl=map'; return url; diff --git a/crm/src/Application/Controllers/SolrController.php b/crm/src/Application/Controllers/SolrController.php index 365b3f68..d6ed33c3 100644 --- a/crm/src/Application/Controllers/SolrController.php +++ b/crm/src/Application/Controllers/SolrController.php @@ -8,9 +8,8 @@ * This proxy URL provides a solution for both these problems. * Request parameters are forwarded to the /solr/select? url * - * @copyright 2013 City of Bloomington, Indiana + * @copyright 2013-2021 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE - * @author Cliff Ingham */ namespace Application\Controllers; @@ -29,9 +28,9 @@ public function index() } $protocol = SOLR_SERVER_PORT==443 ? 'http://' : 'http://'; - $url = $protocol.SOLR_SERVER_HOSTNAME; + $url = $protocol.SOLR_SERVER_HOST; if (SOLR_SERVER_PORT != 80) { $url.= ':'.SOLR_SERVER_PORT; } - $url.= SOLR_SERVER_PATH.'/select?'.$_SERVER['QUERY_STRING']; + $url.= '/solr/'.SOLR_SERVER_CORE.'/select?'.$_SERVER['QUERY_STRING']; echo Url::get($url); exit();