PHP code example of oat-sa / lib-generis-search

1. Go to this page and download the library: Download oat-sa/lib-generis-search 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/ */

    

oat-sa / lib-generis-search example snippets


/* @var $search \oat\oatbox\search\ComplexeSearchService */
$search = $this->getServiceManager()->get(\oat\generis\model\kernel\persistence\smoothsql\search\ComplexSearchService::SERVICE_ID);
/* @var $queryBuilder \oat\search\QueryBuilder */
$queryBuilder = $search->query();
/* search for all test takers */
$query = $search
       ->searchType($queryBuilder, 'http://www.tao.lu/Ontologies/TAOSubject.rdf#Subject' , true)
             ->add('http://www.w3.org/2000/01/rdf-schema#label')
             ->contain('11');

$queryBuilder->setCriteria($query);
/* return an iterator */        
$result = $search->getGateway()->search($queryBuilder);
/* get max result */
echo 'total : ' . $result->total() . '<br><br>';
/*@var $row \core_kernel_classes_Resource */
foreach ($result as $row) {
    /* each iterator entry is a resource object */
    var_dump($row->getLabel());
    echo '<br>';
}