$text = trim($text); if (!$text) { continue; } $noise = 0; if ($text != 'I' && !preg_match('#[a-z!.]#', $text) && $color == 'white') { $noise = 1; } $id = "{$series}-{$epid}-{$rowcount}"; $doc = new XapianDocument(); $indexer->set_document($doc); $doc->set_data($text); $doc->add_term("A{$align}"); $doc->add_term("B{$begin}"); $doc->add_term("C{$color}"); $doc->add_term("E{$epid}"); $doc->add_term("I{$rowcount}"); $doc->add_term("N{$noise}"); $doc->add_term("Q{$id}"); $doc->add_term("S{$series}"); $doc->add_value(0, Xapian::sortable_serialise($beginN)); $doc->add_value(1, sprintf("%d%02d", $series, $epid)); $indexer->index_text($text); $db->add_document($doc); $rowcount++; } $lasttextarr = $safetextarr; } } } $db = null;
public function alert($query, $query_term, $other_term = array(), $sort_id = 0) { try { $this->document = new XapianDocument(); $this->indexer->set_document($this->document); foreach ($query_term as $key => $value) { //$this->indexer->index_text($value, 1, strtoupper($key)); $this->indexer->index_text($value); #$this->indexer->increase_termpos(); } if (!empty($other_term)) { foreach ($other_term as $key => $value) { $this->indexer->index_text($value); #$this->indexer->increase_termpos(); } } $this->document->set_data(json_encode($query)); if (!empty($sort_id)) { $this->document->add_value(0, Xapian::sortable_serialise(intval($sort_id))); } $id_term = $this->_getIdTerm($query[$this->primarykey]); $this->document->add_term($id_term); $this->database->replace_document($id_term, $this->document); $this->database->commit(); } catch (Exception $e) { print $e->getMessage() . "\n"; } }