|
|
@@ -23,21 +23,22 @@ function solr_search($search, $core){ |
|
|
|
} |
|
|
|
else{ |
|
|
|
foreach ($json->response->docs as $result){ |
|
|
|
$id = $result->id; |
|
|
|
$content = $result->content; |
|
|
|
$result_output = parse_result($content); |
|
|
|
$result_output = parse_result($id, $content); |
|
|
|
$output[] = $result_output; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $output; |
|
|
|
} |
|
|
|
|
|
|
|
function solr_search_id($id){ |
|
|
|
function solr_search_id($id, $core){ |
|
|
|
|
|
|
|
// URL encode the ID string |
|
|
|
$id = urlencode($id); |
|
|
|
|
|
|
|
// Assemble a query string to send to Solr. This uses the Solr hostname from config.env. Solr's query syntax can be found at many sites including https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html |
|
|
|
$solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $_ENV["SOLR_CORE"] . '/select?q.op=OR&q=id%3A"' . $id . '"&wt=json'; |
|
|
|
$solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $core . '/select?q.op=OR&q=id%3A"' . $id . '"&wt=json'; |
|
|
|
|
|
|
|
// Perform Curl request on the Solr API |
|
|
|
$ch = curl_init(); |
|
|
@@ -53,19 +54,22 @@ function solr_search_id($id){ |
|
|
|
|
|
|
|
// If no results are found, display a message |
|
|
|
if ($json->response->numFound == '0'){ |
|
|
|
$output = 'No results found'; |
|
|
|
$output = 'no results found'; |
|
|
|
} |
|
|
|
else{ |
|
|
|
foreach ($json->response->docs as $result){ |
|
|
|
$id = $result->id; |
|
|
|
$content = $result->content; |
|
|
|
$result_output = parse_result($content); |
|
|
|
$results[] = $result_output; |
|
|
|
$result_output = parse_result($id, $content); |
|
|
|
$output[] = $result_output; |
|
|
|
} |
|
|
|
} |
|
|
|
return $results; |
|
|
|
return $output; |
|
|
|
} |
|
|
|
|
|
|
|
function parse_result($input){ |
|
|
|
function parse_result($id, $input){ |
|
|
|
|
|
|
|
$output['id'] = $id; |
|
|
|
|
|
|
|
//Set document reference number (used for OPS API) |
|
|
|
preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $input, $doc_ref); |