Example #1
0
 public static function setOptionsXML($client)
 {
     parent::$logger->debug('setOptions');
     $options = new MLPHP\Options($client);
     // Range constraint on session
     $session = new MLPHP\RangeConstraint('session', 'xs:int', 'false', 'bill', '', 'session');
     $options->addConstraint($session);
     // Range constraint on type
     $type = new MLPHP\RangeConstraint('type', 'xs:string', 'false', 'bill', '', 'type');
     $options->addConstraint($type);
     // Range constraint on number
     $type = new MLPHP\RangeConstraint('number', 'xs:int', 'false', 'bill', '', 'number');
     $options->addConstraint($type);
     // Range constraint on abbrev
     $type = new MLPHP\RangeConstraint('abbrev', 'xs:string', 'false', 'bill', '', 'abbrev');
     $options->addConstraint($type);
     // Range constraint on introduced
     $type = new MLPHP\RangeConstraint('introduced', 'xs:string', 'false', 'introduced', '', 'date');
     $options->addConstraint($type);
     // Range constraint on status
     $status = new MLPHP\RangeConstraint('status', 'xs:string', 'true', 'status');
     $options->addConstraint($status);
     // Range constraint on subject
     $keyword = new MLPHP\RangeConstraint('subject', 'xs:string', 'true', 'subject');
     $keyword->setFacetOptions(array('descending', 'frequency-order', 'limit=5'));
     $options->addConstraint($keyword);
     // Range constraint on title
     // $title = new MLPHP\RangeConstraint(
     //     'title', 'xs:string', 'false', 'title'
     // );
     // $options->addConstraint($title);
     // Range constraint on link
     $title = new MLPHP\RangeConstraint('link', 'xs:string', 'false', 'link', '', 'href');
     $options->addConstraint($title);
     // Snippetting prefs
     $transform = new MLPHP\TransformResults('snippet');
     //$pref1 = new MLPHP\PreferredElement('title', '');
     $pref2 = new MLPHP\PreferredElement('summary', '');
     //$transform->addPreferredElements(array($pref1, $pref2));
     $transform->addPreferredElements(array($pref2));
     $options->setTransformResults($transform);
     // Metadata extracts
     $extracts = new MLPHP\Extracts();
     $extracts->addConstraints(array('status', 'subject', 'introduced', 'link', 'session', 'abbrev'));
     $options->setExtracts($extracts);
     $options->setReturnSimilar('true');
     $options->setReturnQuery('true');
     // Term setting
     //$term = new MLPHP\Term("no-results");
     //$options->setTerm($term);
     $options->write('test');
 }
Example #2
0
// Create an Options object (passing the REST client object)
$options8->setReturnConstraints('true');
// Return constraints
$options8->setReturnFacets('false');
// Return facets
$options8->setReturnMetrics('true');
// Return metrics
$options8->setReturnPlan('false');
// Return the plan
$options8->setReturnQtext('true');
// Return the qtext
$options8->setReturnQuery('false');
// Return the query
$options8->setReturnResults('true');
// Return results
$options8->setReturnSimilar('false');
// Return similar documents
$options8->write('options8');
// Write the search options to the database
echo "More options:\n\n";
// Read the options from the database and display
echo htmlspecialchars($options8->read('options8'));
echo "\n\n";
// Term element
$options9 = new MLPHP\Options($client);
// Create an Options object (passing the REST client object)
$term = new MLPHP\Term('no-results');
// Create an Term object
$term->setTermOptions(array('diacritic-insensitive', 'unwildcarded'));
// Set a term setting
$options9->setTerm($term);