Commit ddb05933ee26116a2ac53a80147e9b561b45952e

Authored by Conrad Vermeulen
1 parent de1bf8a2

KTS-2511

"short tag present on phpluceneindexer"
Fixed.

KTS-2398
"Java Lucene Server needs to send the highlighted results back more optimally"
Updated. Had to modify the way results are returned from the php lucene indexer as well

Reviewed By: Kevin Fourie
Committed By: Conrad Vermeulen

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7398 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/indexing/indexers/PHPLuceneIndexer.inc.php
1 -<? 1 +<?php
2 2
3 require_once 'Zend/Search/Lucene.php'; 3 require_once 'Zend/Search/Lucene.php';
4 4
@@ -179,6 +179,8 @@ class PHPLuceneIndexer extends Indexer @@ -179,6 +179,8 @@ class PHPLuceneIndexer extends Indexer
179 public function query($query) 179 public function query($query)
180 { 180 {
181 $results = array(); 181 $results = array();
  182 + $queryDiscussion = stripos($query,'discussion') !== false;
  183 + $queryContent = stripos($query,'content') !== false;
182 $query = Zend_Search_Lucene_Search_QueryParser::parse($query); 184 $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
183 185
184 $hits = $this->lucene->find($query); 186 $hits = $this->lucene->find($query);
@@ -187,15 +189,30 @@ class PHPLuceneIndexer extends Indexer @@ -187,15 +189,30 @@ class PHPLuceneIndexer extends Indexer
187 $document = $hit->getDocument(); 189 $document = $hit->getDocument();
188 190
189 $document_id = PHPLuceneIndexer::stringToLong($document->DocumentID); 191 $document_id = PHPLuceneIndexer::stringToLong($document->DocumentID);
190 - $content = $document->Content ;  
191 - $discussion = $document->Discussion ; 192 +
  193 + $coreText = '';
  194 + if ($queryContent)
  195 + {
  196 + $coreText .= $document->Content;
  197 + }
  198 + if ($queryDiscussion)
  199 + {
  200 + $coreText .= $document->Discussion;
  201 + }
  202 +
  203 + $content = $query->highlightMatches($coreText);
  204 +
192 $title = $document->Title; 205 $title = $document->Title;
193 $score = $hit->score; 206 $score = $hit->score;
194 207
195 // avoid adding duplicates. If it is in already, it has higher priority. 208 // avoid adding duplicates. If it is in already, it has higher priority.
196 if (!array_key_exists($document_id, $results) || $score > $results[$document_id]->Score) 209 if (!array_key_exists($document_id, $results) || $score > $results[$document_id]->Score)
197 { 210 {
198 - $results[$document_id] = new QueryResultItem($document_id, $score, $title, $content, $discussion); 211 + $item = new QueryResultItem($document_id, $score, $title, $content);
  212 + if ($item->CanBeReadByUser)
  213 + {
  214 + $results[$document_id] = $item;
  215 + }
199 } 216 }
200 } 217 }
201 return $results; 218 return $results;