function search($pQuery) { $this->mResults = array(); if (!empty($pQuery) && $this->verifySearchIndex()) { parent::search($pQuery); require_zend_file('Search/Lucene.php'); $index = new ZSearch($this->getField('index_path')); $fields = explode(',', $this->getField('index_fields')); $query = ''; $lowQuery = strtolower($pQuery); foreach ($fields as $f) { $query .= "{$f}:{$lowQuery} OR "; } $query = preg_replace('/ OR $/', '', $query); $this->mResults = $index->find($query); } return count($this->mResults); }
function search($pQuery) { global $gBitSystem; $this->mResults = array(); $this->mHits = 0; if (!empty($pQuery) && $this->verifySearchIndex()) { parent::search($pQuery); // use java wddx $query = $pQuery; java_require(LUCENE_PKG_PATH . 'indexer/lucene.jar;' . LUCENE_PKG_PATH . 'indexer'); $obj = new Java("org.bitweaver.lucene.SearchEngine"); $result = $obj->search($this->getField('index_path'), "OR", $query, $this->getField('index_fields')); if ($meta = $result->get('meta_data')) { $this->mHits = (string) $meta->get('hits'); } else { $this->mHits = 0; } $this->mResults = $result->get('rows'); } return count($this->mResults); }
function search($pQuery) { global $gBitSystem; $this->mResults = array(); if (!empty($pQuery) && $this->verifySearchIndex()) { parent::search($pQuery); // do we have & want php-clucene ? /* Creation of an IndexSearcher instance */ try { $fields = explode(',', $this->getField('index_fields')); if (in_array('title', $fields)) { $searchField = 'title'; } elseif (in_array('data', $fields)) { $searchField = 'data'; } $searcher = new IndexSearcher($this->getField('index_path'), 'title'); $this->mResults = $searcher->search($pQuery); } catch (Exception $e) { $this->mError = 'The search index is unavailable: ' . $e->getMessage(); } } return count($this->mResults); }