Просмотр исходного кода

added search filters for additional Solr indexes

main
Simon Bowie 2 лет назад
Родитель
Сommit
ec5e41d071
4 измененных файлов: 75 добавлений и 69 удалений
  1. +10
    -21
      site/public/index.html
  2. +45
    -40
      site/public/search.php
  3. +5
    -5
      site/solr.php
  4. +15
    -3
      solr_import.sh

+ 10
- 21
site/public/index.html Просмотреть файл

@@ -28,10 +28,18 @@
</div>

<div class="row justify-content-center p-3">
<div class="col-sm-6 text-center"
<div class="col-sm-6 text-center">
<form action="search.php" method="POST">
<input type="text" name="search" placeholder="search for a patent record">
<input type="submit" value="search">
<select name="searchopt" id="searchopt">
<option value="all">all</option>
<option value="active">active</option>
<option value="expanding">expanding</option>
<option value="invisible">invisible</option>
<option value="multispecies">multi-species</option>
<option value="surviving">surviving</option>
</select>
<input type="submit" id="submit" value="search">
</form>
</div>
</div>
@@ -60,25 +68,6 @@
</div>
</div>

<div class="row p-3">
<div class="col text-center">
<form action="search.php" method="POST">
<input type="hidden" name="search" value="leak">
<button type="submit" class="btn-link">
example search: 'leak'
</button>
</form>
</div>

<div class="col text-center">
<form action="search.php" method="POST">
<input type="hidden" name="search" value="secret">
<button type="submit" class="btn-link">
example search: 'secret'
</button>
</form>
</div>
</div>
</div>

</body>

+ 45
- 40
site/public/search.php Просмотреть файл

@@ -26,69 +26,74 @@ include '../solr.php';

<?php

$search_results = solr_search($_POST["search"]);
$search_results = solr_search($_POST["search"], $_POST["searchopt"]);

//print_r($search_results);
if(is_array($search_results)):

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

?>
Application ID:
Application ID:

<?php
echo $result['application_id'];
?>
<?php
echo $result['application_id'];
?>

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

EPO publication:
EPO publication:

<a href=<?php echo $result['epo_publication_url']; ?>>
<?php
echo $result['epo_publication_url'];
?>
</a>
<a href=<?php echo $result['epo_publication_url']; ?>>
<?php
echo $result['epo_publication_url'];
?>
</a>

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

IPC publication:
IPC publication:

<a href=<?php echo $result['ipc_publication_url']; ?>>
<?php
echo $result['ipc_publication_url'];
?>
</a>
<a href=<?php echo $result['ipc_publication_url']; ?>>
<?php
echo $result['ipc_publication_url'];
?>
</a>

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

Title:
Title:

<?php
echo $result['title'];
?>
<?php
echo $result['title'];
?>

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

<?php
if ($result['abstract']):
?>
<?php
if ($result['abstract']):
?>

Abstract:
Abstract:

<?php
echo $result['abstract'];
?>
<?php
echo $result['abstract'];
?>

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

<hr>
<hr>

<?
endif;
?>
<?
endif;
?>

<?php
endforeach;
endforeach;

else:
echo $search_results;

endif;
?>

</div>

+ 5
- 5
site/solr.php Просмотреть файл

@@ -1,9 +1,9 @@
<?php

function solr_search($search){
function solr_search($search, $core){

// 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=content%3A' . $search . '&wt=json';
$solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $core . '/select?q.op=OR&q=content%3A' . $search . '&wt=json';

// Perform Curl request on the Solr API
$ch = curl_init();
@@ -19,16 +19,16 @@ function solr_search($search){

// 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){
$content = $result->content;
$result_output = parse_result($content);
$results[] = $result_output;
$output[] = $result_output;
}
}
return $results;
return $output;
}

function solr_search_id($id){

+ 15
- 3
solr_import.sh Просмотреть файл

@@ -29,11 +29,13 @@ Help()
echo
echo "Syntax: solr_import.sh [-m|h|a|b]"
echo "options:"
echo "m Print the MIT License notification."
echo "l Print the MIT License notification."
echo "h Print this Help."
echo "z Index all."
echo "a Index ACTIVE folder."
echo "e Index EXPANDING folder."
echo "i Index INVISIBLE folder."
echo "m Index MULTI-SPECIES folder."
echo "s Index SURVIVING folder."
echo
}
@@ -59,9 +61,9 @@ Import()
# Set variables

# Get the options
while getopts ":hmzaes" option; do
while getopts ":hlimzaes" option; do
case $option in
m) # display License
l) # display License
License
exit;;
h) # display Help
@@ -82,6 +84,16 @@ while getopts ":hmzaes" option; do
location="Downloads/pop_rtfs/EXPANDING (169)"
Import
exit;;
i) # index INVISIBLE folder
core="invisible"
location="Downloads/pop_rtfs/IN.VISIBLE (204)"
Import
exit;;
m) # index MULTI-SPECIES folder
core="multispecies"
location="Downloads/pop_rtfs/MULTI-SPECIES (180)"
Import
exit;;
s) # index SURVIVING folder
core="surviving"
location="Downloads/pop_rtfs/SURVIVING (166)"

Загрузка…
Отмена
Сохранить