Browse Source

added search filters for additional Solr indexes

main
Simon Bowie 2 years ago
parent
commit
ec5e41d071
4 changed files with 75 additions and 69 deletions
  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 View File

</div> </div>


<div class="row justify-content-center p-3"> <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"> <form action="search.php" method="POST">
<input type="text" name="search" placeholder="search for a patent record"> <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> </form>
</div> </div>
</div> </div>
</div> </div>
</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> </div>


</body> </body>

+ 45
- 40
site/public/search.php View File



<?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 <?php
endforeach;
endforeach;

else:
echo $search_results;

endif;
?> ?>


</div> </div>

+ 5
- 5
site/solr.php View File

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


function solr_search_id($id){ function solr_search_id($id){

+ 15
- 3
solr_import.sh View File

echo echo
echo "Syntax: solr_import.sh [-m|h|a|b]" echo "Syntax: solr_import.sh [-m|h|a|b]"
echo "options:" echo "options:"
echo "m Print the MIT License notification."
echo "l Print the MIT License notification."
echo "h Print this Help." echo "h Print this Help."
echo "z Index all." echo "z Index all."
echo "a Index ACTIVE folder." echo "a Index ACTIVE folder."
echo "e Index EXPANDING folder." echo "e Index EXPANDING folder."
echo "i Index INVISIBLE folder."
echo "m Index MULTI-SPECIES folder."
echo "s Index SURVIVING folder." echo "s Index SURVIVING folder."
echo echo
} }
# Set variables # Set variables


# Get the options # Get the options
while getopts ":hmzaes" option; do
while getopts ":hlimzaes" option; do
case $option in case $option in
m) # display License
l) # display License
License License
exit;; exit;;
h) # display Help h) # display Help
location="Downloads/pop_rtfs/EXPANDING (169)" location="Downloads/pop_rtfs/EXPANDING (169)"
Import Import
exit;; 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 s) # index SURVIVING folder
core="surviving" core="surviving"
location="Downloads/pop_rtfs/SURVIVING (166)" location="Downloads/pop_rtfs/SURVIVING (166)"

Loading…
Cancel
Save