Ejemplo n.º 1
0
 function testFacets()
 {
     parent::$logger->debug('testFacets');
     $options = new MLPHP\Options(parent::$client, 'testFacets');
     $constraint = new MLPHP\RangeConstraint('subject', 'xs:string', 'true', 'subject');
     $constraint->setFacetOptions(array('descending', 'frequency-order', 'limit=5'));
     $options->addConstraint($constraint)->write();
     $search = new MLPHP\Search(parent::$client, 1, 3);
     $results = $search->retrieve('', array('options' => 'testFacets'));
     $facetVals = $results->getFacet('subject')->getFacetValues();
     $this->assertCount(5, $facetVals);
     $this->assertEquals('Commemorations', $facetVals[3]->getName());
     $this->assertGreaterThan($facetVals[4]->getCount(), $facetVals[0]->getCount());
 }
Ejemplo n.º 2
0
 $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));
 $options->setTransformResults($transform);
 // Metadata extracts
 $extracts = new MLPHP\Extracts();
Ejemplo n.º 3
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');
 }