Browse Source

Fixed some issues with solr queries that caused errors. Added trim and escaping to strings before building query.

pull/105/head
=Mark Roy 14 years ago
parent
commit
79b6656711
  1. 12
      form_elements/includes/autocomplete.inc

12
form_elements/includes/autocomplete.inc

@ -3,7 +3,7 @@
// $Id$ // $Id$
function ife_autocomplete_person($string) { function ife_autocomplete_person($string) {
$string=strtolower($string); $string=trim(strtolower($string));
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('php', 'islandora_solr_search', 'Solr/Service'); module_load_include('php', 'islandora_solr_search', 'Solr/Service');
@ -12,9 +12,11 @@ function ife_autocomplete_person($string) {
$appName = variable_get('islandora_solr_search_block_app_name','solr'); $appName = variable_get('islandora_solr_search_block_app_name','solr');
$requestHandler = variable_get("islandora_solr_search_block_request_handler",t("standard")); $requestHandler = variable_get("islandora_solr_search_block_request_handler",t("standard"));
$query = 'name_personal_t:'.$string.'* OR name_organization_t:'.$string.'* OR name_conference_t:'.$string.'*';
$solr = new Apache_Solr_Service($host, $port, '/'.$appName.'/'); $solr = new Apache_Solr_Service($host, $port, '/'.$appName.'/');
$string=$solr->escape($string);
$query = 'name_personal_t:'.$string.'* OR name_organization_t:'.$string.'* OR name_conference_t:'.$string.'*';
$additionalParams = array( $additionalParams = array(
'facet' => 'false', 'facet' => 'false',
'qt' => $requestHandler, 'qt' => $requestHandler,
@ -129,7 +131,7 @@ function ife_autocomplete_gacs($collection, $string='') {
$collection = FALSE; $collection = FALSE;
} }
$string=ucwords($string); $string=ucwords(trim($string));
$dom = DOMDocument::load ( $moduleRoot .'/xml/gacs.xml' ); $dom = DOMDocument::load ( $moduleRoot .'/xml/gacs.xml' );
$rootEl = $dom->getElementsByTagName('codelist'); $rootEl = $dom->getElementsByTagName('codelist');
@ -159,7 +161,7 @@ function ife_autocomplete_language($collection, $string='') {
$collection = FALSE; $collection = FALSE;
} }
$string=ucwords($string); $string=ucwords(trim($string));
$dom = DOMDocument::load ( $moduleRoot .'/xml/languages.xml' ); $dom = DOMDocument::load ( $moduleRoot .'/xml/languages.xml' );
$rootEl = $dom->getElementsByTagName('codelist'); $rootEl = $dom->getElementsByTagName('codelist');
@ -197,7 +199,7 @@ function ife_autocomplete($field, $collection, $string='') {
'fl' => $field 'fl' => $field
); );
$query = $field .':'. $solr->escape(strtolower($string)) .'*'; $query = $field .':'. $solr->escape(strtolower(trim($string))) .'*';
if ($collection != FALSE) { if ($collection != FALSE) {
$query .= ' AND related_item_identifier_t:'. $solr->escape($collection); $query .= ' AND related_item_identifier_t:'. $solr->escape($collection);

Loading…
Cancel
Save