Преглед изворни кода

enabled id search on search results page

main
Simon Bowie пре 2 година
родитељ
комит
aa22029fa8
4 измењених фајлова са 24 додато и 12 уклоњено
  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 Прегледај датотеку

@@ -27,7 +27,9 @@ include '../ops_api.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):

@@ -134,6 +136,11 @@ include '../ops_api.php'

<?php
endforeach;

else:
echo $search_results;

endif;
?>

</div>

+ 2
- 1
site/public/search.php Прегледај датотеку

@@ -35,9 +35,11 @@ include '../solr.php';
?>
Application ID:

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

<br><br>

@@ -92,7 +94,6 @@ include '../solr.php';

else:
echo $search_results;

endif;
?>


+ 1
- 1
site/public/titles.php Прегледај датотеку

@@ -34,7 +34,7 @@ foreach ($random_titles as $record_array):
<?
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;
?>

+ 13
- 9
site/solr.php Прегледај датотеку

@@ -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);

Loading…
Откажи
Сачувај