$client = $mlphp->newClient(); $client->setUsername($mlphp->config['username-admin']); $client->setPassword($mlphp->config['password-admin']); // Set up options node $options = new MLPHP\Options($client); $latConstraint = new MLPHP\RangeConstraint('latitude', 'xs:float', 'false', 'latitude'); $latConstraint->setFragmentScrope('properties'); $options->addConstraint($latConstraint); $lonConstraint = new MLPHP\RangeConstraint('longitude', 'xs:float', 'false', 'longitude'); $lonConstraint->setFragmentScrope('properties'); $options->addConstraint($lonConstraint); $hConstraint = new MLPHP\RangeConstraint('height', 'xs:int', 'false', 'height'); $hConstraint->setFragmentScrope('properties'); $options->addConstraint($hConstraint); $wConstraint = new MLPHP\RangeConstraint('width', 'xs:int', 'false', 'width'); $wConstraint->setFragmentScrope('properties'); $options->addConstraint($wConstraint); $fConstraint = new MLPHP\RangeConstraint('filename', 'xs:string', 'false', 'filename'); $fConstraint->setFragmentScrope('properties'); $options->addConstraint($fConstraint); $extracts = new MLPHP\Extracts(); $extracts->addConstraints(array('latitude', 'longitude', 'height', 'width', 'filename')); $options->setExtracts($extracts); // Write to database $optionsid = 'photomap'; $response = $options->write($optionsid); echo '<!--' . $options->read($optionsid) . '-->' . PHP_EOL; $_SESSION['options_loaded_photomap'] = TRUE; } else { echo '<!-- Search options already loaded -->' . PHP_EOL; }
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Setup use MarkLogic\MLPHP; require_once 'setup.php'; $client = $mlphp->newClient(); $client->setUsername($mlphp->config['username-admin']); $client->setPassword($mlphp->config['password-admin']); // Range constraint and extracted metadata $options1 = new MLPHP\Options($client); // Create an Options object (passing the REST client) $range = new MLPHP\RangeConstraint('film', 'xs:string', 'true', 'film-title', 'http://marklogic.com/wikipedia', '', ''); // Set attribute namespace $range->setFragmentScrope('documents'); // Set fragment scope $options1->addConstraint($range); // Add the constraint to the Options object $extracts1 = new MLPHP\Extracts(); // Create an Extracts object (for extracted metadata) $extracts1->addConstraints('film'); // Add the constraint as extracted metadata $options1->setExtracts($extracts1); // Set the extracted metadata in the Options object $options1->write('options1'); // Write the search options to the database // Read the options from the database and display echo "Range constraint and extracted metadata:\n\n"; echo htmlspecialchars($options1->read('options1')); echo "\n\n";