// 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; $_SESSION['options_loaded_usbills'] = TRUE; } else { echo '<!-- Search options already loaded -->' . PHP_EOL; }
// 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); // Set the Term object in the options $options9->write('options9'); // Write the search options to the database // Read the options from the database and display echo "Term options:\n\n"; echo htmlspecialchars($options9->read('options9')); echo "\n\n"; // Delete the example options from the database $num = 9; for ($i = 1; $i <= $num; $i++) { $options1->delete('options' . $i); }