Commit 0fe907b186687b093269c9358988789b35bf4626
1 parent
5fd1847b
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
Showing
1 changed file
with
21 additions
and
4 deletions
search2/indexing/indexers/PHPLuceneIndexer.inc.php
| 1 | -<? | |
| 1 | +<?php | |
| 2 | 2 | |
| 3 | 3 | require_once 'Zend/Search/Lucene.php'; |
| 4 | 4 | |
| ... | ... | @@ -179,6 +179,8 @@ class PHPLuceneIndexer extends Indexer |
| 179 | 179 | public function query($query) |
| 180 | 180 | { |
| 181 | 181 | $results = array(); |
| 182 | + $queryDiscussion = stripos($query,'discussion') !== false; | |
| 183 | + $queryContent = stripos($query,'content') !== false; | |
| 182 | 184 | $query = Zend_Search_Lucene_Search_QueryParser::parse($query); |
| 183 | 185 | |
| 184 | 186 | $hits = $this->lucene->find($query); |
| ... | ... | @@ -187,15 +189,30 @@ class PHPLuceneIndexer extends Indexer |
| 187 | 189 | $document = $hit->getDocument(); |
| 188 | 190 | |
| 189 | 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 | 205 | $title = $document->Title; |
| 193 | 206 | $score = $hit->score; |
| 194 | 207 | |
| 195 | 208 | // avoid adding duplicates. If it is in already, it has higher priority. |
| 196 | 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 | 218 | return $results; | ... | ... |