コード例 #1
0
/** create a temporary directory for the lucene index files. Make sure
 * to create the tmpdir from Java so that the directory has
 * javabridge_tmp_t Security Enhanced Linux permission. Note that PHP
 * does not have access to tempfiles with java_bridge_tmp_t: PHP
 * inherits the rights from the HTTPD, usually httpd_tmp_t.
 */
function create_index_dir()
{
    global $tmp_file, $tmp_dir;
    $javaTmpdir = java("java.lang.System")->getProperty("java.io.tmpdir");
    $tmpdir = java_values($javaTmpdir);
    $tmp_file = tempnam($tmpdir, "idx");
    $tmp_dir = new java("java.io.File", "{$tmp_file}.d");
    $tmp_dir->mkdir();
    return java_values($tmp_dir->toString());
}
コード例 #2
0
$analyzer = new java("org.apache.lucene.analysis.standard.StandardAnalyzer");
foreach ($plugins as $plugin) {
    if ($plugin->type == 'SearchLucene') {
        $startDate = date('Y/m/d H:i');
        if (!is_object($dispatcher)) {
            $dispatcher =& JDispatcher::getInstance();
        }
        $path = JPATH_PLUGINS . DS . $plugin->type . DS . $plugin->name . '.php';
        $className = 'plg' . $plugin->type . $plugin->name;
        require_once $path;
        echo $className;
        $instance = new $className($dispatcher, $plugin);
        $pluginindex = $indexpath . DS . $plugin->name;
        $index = new java("java.io.File", $pluginindex);
        if (!$index->exists()) {
            $index->mkdir();
        }
        $writer = new java("org.apache.lucene.index.IndexWriter", $index, $analyzer, true);
        $fields = $instance->indexerGetFields();
        if ($fields) {
            while ($data = $instance->indexerGetData()) {
                // Results can be packed in an array of array('resultset' => $results)
                // or can be returned one by one.
                // Every result can be an object or an array.
                // every field will be accessed in object->field or array['field'] manner
                // depending on the result type
                if (is_array($data) && isset($data['resultset']) && count($data['resultset']) > 0) {
                    foreach ($data['resultset'] as $data) {
                        if ($data != null) {
                            indexData($writer, $fields, $data);
                        }