diff --git a/search2/indexing/indexers/PHPLuceneIndexer.inc.php b/search2/indexing/indexers/PHPLuceneIndexer.inc.php index bc44879..640bc32 100755 --- a/search2/indexing/indexers/PHPLuceneIndexer.inc.php +++ b/search2/indexing/indexers/PHPLuceneIndexer.inc.php @@ -7,31 +7,31 @@ * Document Management Made Simple * Copyright (C) 2008, 2009 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original + * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * @@ -67,9 +67,13 @@ class PHPLuceneIndexer extends Indexer } catch(Exception $ex) { - $this->lucene = null; - if (!$catchException) - throw $ex; + if($ex->getMessage() == "Index doesn't exists in the specified directory."){ + $this->lucene = new Zend_Search_Lucene($indexPath, true); + }else { + $this->lucene = null; + if (!$catchException) + throw $ex; + } } } @@ -94,13 +98,16 @@ class PHPLuceneIndexer extends Indexer */ private function addDocument($docid, $content, $discussion, $title, $version) { - $doc = new Zend_Search_Lucene_Document(); - $doc->addField(Zend_Search_Lucene_Field::Text('DocumentID', PHPLuceneIndexer::longToString($docid))); - $doc->addField(Zend_Search_Lucene_Field::Text('Content', $content, 'UTF-8')); - $doc->addField(Zend_Search_Lucene_Field::Text('Discussion', $discussion, 'UTF-8')); - $doc->addField(Zend_Search_Lucene_Field::Text('Title', $title, 'UTF-8')); - $doc->addField(Zend_Search_Lucene_Field::Text('Version', $version, 'UTF-8')); - $this->lucene->addDocument($doc); + $teaser = substr($content, 0, 250); + + $doc = new Zend_Search_Lucene_Document(); + $doc->addField(Zend_Search_Lucene_Field::Text('DocumentID', PHPLuceneIndexer::longToString($docid))); + $doc->addField(Zend_Search_Lucene_Field::Text('Content', $content, 'UTF-8')); + $doc->addField(Zend_Search_Lucene_Field::unStored('Discussion', $discussion, 'UTF-8')); + $doc->addField(Zend_Search_Lucene_Field::Text('Title', $title, 'UTF-8')); + $doc->addField(Zend_Search_Lucene_Field::Text('Version', $version, 'UTF-8')); + $doc->addField(Zend_Search_Lucene_Field::unIndexed('Summary', $teaser, 'UTF-8')); + $this->lucene->addDocument($doc); } /** @@ -232,6 +239,7 @@ class PHPLuceneIndexer extends Indexer $document_id = PHPLuceneIndexer::stringToLong($document->DocumentID); + /* $coreText = ''; if ($queryContent) { @@ -243,6 +251,11 @@ class PHPLuceneIndexer extends Indexer } $content = $query->highlightMatches($coreText); + */ + + $teaser = $document->Summary; + + $content = $query->highlightMatches($teaser); $title = $document->Title; $score = $hit->score; @@ -250,6 +263,7 @@ class PHPLuceneIndexer extends Indexer // avoid adding duplicates. If it is in already, it has higher priority. if (!array_key_exists($document_id, $results) || $score > $results[$document_id]->Score) { + $item = new DocumentResultItem($document_id, $score, $title, $content); $item = new QueryResultItem($document_id, $score, $title, $content); if ($item->CanBeReadByUser) { @@ -284,4 +298,8 @@ class PHPLuceneIndexer extends Indexer return _kt('Document Indexer Library'); } } -?> + + public function isDocumentIndexed($documentId){ + // do something + } +?> \ No newline at end of file