|
|
|
@ -101,28 +101,31 @@ abstract class XapianIndexer { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function index() { |
|
|
|
function index() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
foreach ($this->chunks as $chunk) { |
|
|
|
if (!empty($this->chunks)) { |
|
|
|
$doc = new XapianDocument(); |
|
|
|
foreach ($this->chunks as $chunk) { |
|
|
|
$this->indexer->set_document($doc); |
|
|
|
$doc = new XapianDocument(); |
|
|
|
|
|
|
|
$this->indexer->set_document($doc); |
|
|
|
foreach ($chunk->terms as $term) { |
|
|
|
if (!empty($chunk->terms)) { |
|
|
|
/* FIXME: think of getting weight */ |
|
|
|
foreach ($chunk->terms as $term) { |
|
|
|
$doc->add_term($term['flag'] . $term['name'], 1); |
|
|
|
/* FIXME: think of getting weight */ |
|
|
|
} |
|
|
|
$doc->add_term($term['flag'] . $term['name'], 1); |
|
|
|
|
|
|
|
} |
|
|
|
// free-form index all data array (title, content, etc) |
|
|
|
} |
|
|
|
foreach ($chunk->data as $key => $value) { |
|
|
|
|
|
|
|
$this->indexer->index_text($value, 1); |
|
|
|
// free-form index all data array (title, content, etc) |
|
|
|
|
|
|
|
if (!empty($chunk->data)) { |
|
|
|
|
|
|
|
foreach ($chunk->data as $key => $value) { |
|
|
|
|
|
|
|
$this->indexer->index_text($value, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$doc->set_data($chunk->xapian_data, 1); |
|
|
|
|
|
|
|
$did = $this->db->add_document($doc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//write to disk |
|
|
|
|
|
|
|
$this->db->flush(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $did; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$doc->set_data($chunk->xapian_data, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$did = $this->db->add_document($doc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//write to disk |
|
|
|
|
|
|
|
$this->db->flush(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $did; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception $e) { |
|
|
|
catch (Exception $e) { |
|
|
|
|