PHP code example of ritterg / sru-ao

1. Go to this page and download the library: Download ritterg/sru-ao library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ritterg / sru-ao example snippets


use Ritterg\SruAo\SruQuery;

$sruquery = new SruQuery;
$searchparams = $sruquery->getQueryParams($request, $allowedfields = null, $allowedoperators = null);

$allowedfields = [
	'Serverchoice' => 'fulltext', 
	'isad.reference' => 'reference', 
	'isad.title' => 'title', 
	'isad.date' => 'date', 
];

$allowedoperators = [  
	'all' => 'AND',  
	'any' => 'OR',  
	'adj' => 'ADJ',  
	'=' => 'LIKE',  
	'==' => 'LIKE',  
	'===' => '=',  
	'WITHIN' => '='  
];

$searchparams = [
  "fulltext" => [
    "value" => "Switzerland Germany"
    "operator" => "AND"
  ]
  "date_start" => [
    "value" => "1000-01-01"
    "operator" => ">="
  ]
  "date_end" => [
    "value" => "2000-12-31"
    "operator" => "<="
  ]
  "limit" => 50
]

use Ritterg\SruAo\SruQuery;

$sruresponse = new SruResponse;
$xml = $sruresponse->composeSruResponse($results, $totalcount, $keys);

$keys = [
'reference' => 'signatur',
'title' => 'titel',
'date' => 'datum',
'descriptionlevel' => 'stufe',
'extend' => 'umfang',
'creator' => 'autor',
'score' => 'relevanz',
'link' => 'url',
'beginDateISO' => 'anfangsdatum',
'beginApprox' => 'anfangca',
'endDateISO' => 'enddatum',
'endApprox' => 'endca',
'hasDigitizedItems' => 'digitalisate',
];