Beispiel #1
0
 function testExtracts()
 {
     parent::$logger->debug('testExtracts');
     $options = new MLPHP\Options(parent::$client);
     $extracts = new MLPHP\Extracts();
     $extracts->addConstraints('foo');
     $extracts->addQName('bar', 'http://example.com/bar', 'baz', 'http://example.com/baz');
     $options->setExtracts($extracts);
     $this->assertXmlStringEqualsXmlString('
       <options xmlns="http://marklogic.com/appservices/search">
         <extract-metadata>
           <constraint-value ref="foo"/>
           <qname elem-name="bar" elem-ns="http://example.com/bar"
             attr-name="baz" attr-ns="http://example.com/baz"/>
         </extract-metadata>
       </options>
     ', $options->getAsXML());
 }
Beispiel #2
0
 function testExtractQName()
 {
     // @todo not working, https://github.com/marklogic/mlphp/issues/6
     parent::$logger->debug('testExtractQName');
     $options = new MLPHP\Options(parent::$client, 'testExtractQName');
     $constraint = new MLPHP\RangeConstraint('title', 'xs:string', 'false', 'title');
     $options->addConstraint($constraint);
     $extracts = new MLPHP\Extracts();
     $extracts->addQName('status');
     $extracts->addConstraints(array('title'));
     $options->setExtracts($extracts)->write();
     $search = new MLPHP\Search(parent::$client, 1, 2);
     $results = $search->retrieve('', array('options' => 'testExtractQName', 'collection' => 'h'));
     $this->assertEquals('', $results->getResultByIndex(1)->getMetadata('status')[0]);
 }
Beispiel #3
0
$options4->write('options4');
// Write the search options to the database
// Read the options from the database and display
echo "Field word constraint:\n\n";
echo htmlspecialchars($options4->read('options4'));
echo "\n\n";
// Collection constraint with metadata
$options5 = new MLPHP\Options($client);
// Create an Options object (passing the REST client object)
$collection = new MLPHP\CollectionConstraint('tag', 'http://example.com/tag/');
// Set prefix
$options5->addConstraint($collection);
// Add the constraint to the Options object
$extracts5 = new MLPHP\Extracts();
// Create an Extracts object (for extracted metadata)
$extracts5->addQName('film-title', 'http://marklogic.com/wikipedia');
// Set element namespace
$options5->setExtracts($extracts5);
// Set the extracted metadata in the Options object
$options5->write('options5');
// Write the search options to the database
// Read the options from the database and display
echo "Collection constraint with metadata:\n\n";
echo htmlspecialchars($options5->read('options5'));
echo "\n\n";
// Element-query constraint
$options6 = new MLPHP\Options($client);
// Create an Options object (passing the REST client object)
$eq = new MLPHP\ElementQueryConstraint('title', 'title', 'http://my/namespace');
// Set element namespace
$options6->addConstraint($eq);