function testTransformResults() { parent::$logger->debug('testTransformResults'); $options = new MLPHP\Options(parent::$client); $tr = new MLPHP\TransformResults('myTransform'); $pe1 = new MLPHP\PreferredElement('foo', 'http://example.com/foo'); $pe2 = new MLPHP\PreferredElement('bar', 'http://example.com/bar'); $tr->addPreferredElements([$pe1, $pe2]); $options->setTransformResults($tr); $this->assertXmlStringEqualsXmlString(' <options xmlns="http://marklogic.com/appservices/search"> <transform-results apply="myTransform"> <preferred-elements> <element name="foo" ns="http://example.com/foo"/> <element name="bar" ns="http://example.com/bar"/> </preferred-elements> </transform-results> </options> ', $options->getAsXML()); }
$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(); $extracts->addConstraints(array('title', 'status', 'subject', 'introduced', 'link', 'session', 'abbrev')); $options->setExtracts($extracts); // Term setting //$term = new MLPHP\Term("no-results"); //$options->setTerm($term); // Write to database $optionsid = 'usbills'; $response = $options->write($optionsid); echo '<!--' . $options->read($optionsid) . '-->' . PHP_EOL;
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'); }