Commit f4c63877ef67eea3230ede0a1411411aa9ae6549

Authored by conradverm
1 parent a3e5e558

KTS-673

"The search algorithm needs some work"
Updated. 

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7241 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/indexing/indexerCore.inc.php
... ... @@ -42,6 +42,7 @@ class MatchResult
42 42 default:
43 43 throw new Exception("Unknown property '$property' to get on MatchResult");
44 44 }
  45 + return true; // should not be reached
45 46 }
46 47  
47 48 private function loadDocumentInfo()
... ... @@ -142,6 +143,7 @@ class MatchResult
142 143 default:
143 144 throw new Exception("Unknown property '$property' to get on MatchResult");
144 145 }
  146 + return ''; // Should not be reached
145 147 }
146 148  
147 149 protected function __set($property, $value)
... ... @@ -543,6 +545,7 @@ abstract class Indexer
543 545  
544 546 Indexer::clearoutDeleted();
545 547  
  548 + $date = date('Y-m-d H:j:s');
546 549 // identify the indexers that must run
547 550 // mysql specific limit!
548 551 $sql = "SELECT
... ... @@ -554,7 +557,7 @@ abstract class Indexer
554 557 INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
555 558 INNER JOIN mime_types mt ON dcv.mime_id=mt.id
556 559 WHERE
557   - iff.processdate IS NULL AND dmv.status_id=1
  560 + (iff.processdate IS NULL or iff.processdate < cast(cast('$date' as date) -1 as date)) AND dmv.status_id=1
558 561 ORDER BY indexdate
559 562 LIMIT $max";
560 563 $result = DBUtil::getResultArray($sql);
... ... @@ -578,7 +581,7 @@ abstract class Indexer
578 581 }
579 582  
580 583 // mark the documents as being processed
581   - $date = date('Y-m-d H:j:s');
  584 +
582 585 $ids=implode(',',$ids);
583 586 $sql = "UPDATE index_files SET processdate='$date' WHERE document_id in ($ids)";
584 587 DBUtil::runQuery($sql);
... ... @@ -640,6 +643,7 @@ abstract class Indexer
640 643 }
641 644  
642 645 $document = Document::get($docId);
  646 + $version = $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber();
643 647 $sourceFile = $storageManager->temporaryFile($document);
644 648  
645 649 if (empty($sourceFile) || !is_file($sourceFile))
... ... @@ -655,7 +659,7 @@ abstract class Indexer
655 659 $result = @copy($sourceFile, $intermediate);
656 660 if ($result === false)
657 661 {
658   - $default->log->error("Could not create intermediate file from document $docid");
  662 + $default->log->error("Could not create intermediate file from document $docId");
659 663 // problem. lets try again later. probably permission related. log the issue.
660 664 continue;
661 665 }
... ... @@ -685,7 +689,7 @@ abstract class Indexer
685 689 $title = $document->getName();
686 690 if ($indexDiscussion)
687 691 {
688   - $indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title);
  692 + $indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title, $version);
689 693  
690 694 if (!$indexStatus) $default->log->error("Problem indexing document $docId");
691 695  
... ... @@ -699,7 +703,7 @@ abstract class Indexer
699 703 }
700 704 else
701 705 {
702   - $indexStatus = $this->indexDocument($docId, $targetFile, $title);
  706 + $indexStatus = $this->indexDocument($docId, $targetFile, $title, $version);
703 707  
704 708 if (!$indexStatus) $default->log->error("Problem indexing document $docId");
705 709  
... ... @@ -744,7 +748,7 @@ abstract class Indexer
744 748 * @param int $docId
745 749 * @param string $textFile
746 750 */
747   - protected abstract function indexDocument($docId, $textFile, $title='');
  751 + protected abstract function indexDocument($docId, $textFile, $title, $version);
748 752  
749 753 /**
750 754 * Index a discussion. The base class must override this function.
... ... @@ -848,18 +852,17 @@ abstract class Indexer
848 852 require_once($this->extractorPath . '/' . $file);
849 853 $class = substr($file, 0, -8);
850 854  
851   - if (class_exists($class))
  855 + if (!class_exists($class))
852 856 {
  857 + // if the class does not exist, we can't do anything.
853 858 continue;
854 859 }
855 860  
856 861 $extractor = new $class;
857   - if (!($class instanceof DocumentExtractor))
  862 + if ($extractor instanceof DocumentExtractor)
858 863 {
859   - continue;
  864 + $extractor->registerMimeTypes();
860 865 }
861   -
862   - $extractor->registerMimeTypes();
863 866 }
864 867 }
865 868 closedir($dir);
... ... @@ -871,9 +874,9 @@ abstract class Indexer
871 874 * @param int $docId
872 875 * @param string $textFile
873 876 */
874   - protected function indexDocumentAndDiscussion($docId, $textFile, $title='')
  877 + protected function indexDocumentAndDiscussion($docId, $textFile, $title, $version)
875 878 {
876   - $this->indexDocument($docId, $textFile, $title);
  879 + $this->indexDocument($docId, $textFile, $title, $version);
877 880 $this->indexDiscussion($docId);
878 881 }
879 882  
... ...