Browse Source

enabled id search on search results page

main
Simon Bowie 2 years ago
parent
commit
aa22029fa8
4 changed files with 24 additions and 12 deletions
  1. +8
    -1
      site/public/id_search.php
  2. +2
    -1
      site/public/search.php
  3. +1
    -1
      site/public/titles.php
  4. +13
    -9
      site/solr.php

+ 8
- 1
site/public/id_search.php View File



<?php <?php


$search_results = solr_search_id($_GET["id"]);
$search_results = solr_search_id($_GET["id"], $_GET["core"]);

if(is_array($search_results)):


foreach($search_results as $result): foreach($search_results as $result):




<?php <?php
endforeach; endforeach;

else:
echo $search_results;

endif;
?> ?>


</div> </div>

+ 2
- 1
site/public/search.php View File

?> ?>
Application ID: Application ID:


<a href="id_search.php?id=<? echo $result['id']; ?>&core=<? echo $_POST['searchopt']; ?>">
<?php <?php
echo $result['application_id']; echo $result['application_id'];
?> ?>
</a>


<br><br> <br><br>




else: else:
echo $search_results; echo $search_results;

endif; endif;
?> ?>



+ 1
- 1
site/public/titles.php View File

<? <?
foreach ($record_array as $id => $title): foreach ($record_array as $id => $title):
?> ?>
<a href="id_search.php?id=<? echo $id; ?>">
<a href="id_search.php?id=<? echo $id; ?>&core=all">
<? <?
echo $title; echo $title;
?> ?>

+ 13
- 9
site/solr.php View File

} }
else{ else{
foreach ($json->response->docs as $result){ foreach ($json->response->docs as $result){
$id = $result->id;
$content = $result->content; $content = $result->content;
$result_output = parse_result($content);
$result_output = parse_result($id, $content);
$output[] = $result_output; $output[] = $result_output;
}
}
} }
return $output; return $output;
} }


function solr_search_id($id){
function solr_search_id($id, $core){


// URL encode the ID string // URL encode the ID string
$id = urlencode($id); $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 // 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 // Perform Curl request on the Solr API
$ch = curl_init(); $ch = curl_init();


// If no results are found, display a message // If no results are found, display a message
if ($json->response->numFound == '0'){ if ($json->response->numFound == '0'){
$output = 'No results found';
$output = 'no results found';
} }
else{ else{
foreach ($json->response->docs as $result){ foreach ($json->response->docs as $result){
$id = $result->id;
$content = $result->content; $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) //Set document reference number (used for OPS API)
preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $input, $doc_ref); preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $input, $doc_ref);

Loading…
Cancel
Save