Commit 0d2e39b56106da599ccbdce86674f301fc17690b

Authored by Conrad Vermeulen
1 parent 5eaf2ceb

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,6 +42,7 @@ class MatchResult
42 default: 42 default:
43 throw new Exception("Unknown property '$property' to get on MatchResult"); 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 private function loadDocumentInfo() 48 private function loadDocumentInfo()
@@ -142,6 +143,7 @@ class MatchResult @@ -142,6 +143,7 @@ class MatchResult
142 default: 143 default:
143 throw new Exception("Unknown property '$property' to get on MatchResult"); 144 throw new Exception("Unknown property '$property' to get on MatchResult");
144 } 145 }
  146 + return ''; // Should not be reached
145 } 147 }
146 148
147 protected function __set($property, $value) 149 protected function __set($property, $value)
@@ -543,6 +545,7 @@ abstract class Indexer @@ -543,6 +545,7 @@ abstract class Indexer
543 545
544 Indexer::clearoutDeleted(); 546 Indexer::clearoutDeleted();
545 547
  548 + $date = date('Y-m-d H:j:s');
546 // identify the indexers that must run 549 // identify the indexers that must run
547 // mysql specific limit! 550 // mysql specific limit!
548 $sql = "SELECT 551 $sql = "SELECT
@@ -554,7 +557,7 @@ abstract class Indexer @@ -554,7 +557,7 @@ abstract class Indexer
554 INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id 557 INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id
555 INNER JOIN mime_types mt ON dcv.mime_id=mt.id 558 INNER JOIN mime_types mt ON dcv.mime_id=mt.id
556 WHERE 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 ORDER BY indexdate 561 ORDER BY indexdate
559 LIMIT $max"; 562 LIMIT $max";
560 $result = DBUtil::getResultArray($sql); 563 $result = DBUtil::getResultArray($sql);
@@ -578,7 +581,7 @@ abstract class Indexer @@ -578,7 +581,7 @@ abstract class Indexer
578 } 581 }
579 582
580 // mark the documents as being processed 583 // mark the documents as being processed
581 - $date = date('Y-m-d H:j:s'); 584 +
582 $ids=implode(',',$ids); 585 $ids=implode(',',$ids);
583 $sql = "UPDATE index_files SET processdate='$date' WHERE document_id in ($ids)"; 586 $sql = "UPDATE index_files SET processdate='$date' WHERE document_id in ($ids)";
584 DBUtil::runQuery($sql); 587 DBUtil::runQuery($sql);
@@ -640,6 +643,7 @@ abstract class Indexer @@ -640,6 +643,7 @@ abstract class Indexer
640 } 643 }
641 644
642 $document = Document::get($docId); 645 $document = Document::get($docId);
  646 + $version = $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber();
643 $sourceFile = $storageManager->temporaryFile($document); 647 $sourceFile = $storageManager->temporaryFile($document);
644 648
645 if (empty($sourceFile) || !is_file($sourceFile)) 649 if (empty($sourceFile) || !is_file($sourceFile))
@@ -655,7 +659,7 @@ abstract class Indexer @@ -655,7 +659,7 @@ abstract class Indexer
655 $result = @copy($sourceFile, $intermediate); 659 $result = @copy($sourceFile, $intermediate);
656 if ($result === false) 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 // problem. lets try again later. probably permission related. log the issue. 663 // problem. lets try again later. probably permission related. log the issue.
660 continue; 664 continue;
661 } 665 }
@@ -685,7 +689,7 @@ abstract class Indexer @@ -685,7 +689,7 @@ abstract class Indexer
685 $title = $document->getName(); 689 $title = $document->getName();
686 if ($indexDiscussion) 690 if ($indexDiscussion)
687 { 691 {
688 - $indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title); 692 + $indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title, $version);
689 693
690 if (!$indexStatus) $default->log->error("Problem indexing document $docId"); 694 if (!$indexStatus) $default->log->error("Problem indexing document $docId");
691 695
@@ -699,7 +703,7 @@ abstract class Indexer @@ -699,7 +703,7 @@ abstract class Indexer
699 } 703 }
700 else 704 else
701 { 705 {
702 - $indexStatus = $this->indexDocument($docId, $targetFile, $title); 706 + $indexStatus = $this->indexDocument($docId, $targetFile, $title, $version);
703 707
704 if (!$indexStatus) $default->log->error("Problem indexing document $docId"); 708 if (!$indexStatus) $default->log->error("Problem indexing document $docId");
705 709
@@ -744,7 +748,7 @@ abstract class Indexer @@ -744,7 +748,7 @@ abstract class Indexer
744 * @param int $docId 748 * @param int $docId
745 * @param string $textFile 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 * Index a discussion. The base class must override this function. 754 * Index a discussion. The base class must override this function.
@@ -848,18 +852,17 @@ abstract class Indexer @@ -848,18 +852,17 @@ abstract class Indexer
848 require_once($this->extractorPath . '/' . $file); 852 require_once($this->extractorPath . '/' . $file);
849 $class = substr($file, 0, -8); 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 continue; 858 continue;
854 } 859 }
855 860
856 $extractor = new $class; 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 closedir($dir); 868 closedir($dir);
@@ -871,9 +874,9 @@ abstract class Indexer @@ -871,9 +874,9 @@ abstract class Indexer
871 * @param int $docId 874 * @param int $docId
872 * @param string $textFile 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 $this->indexDiscussion($docId); 880 $this->indexDiscussion($docId);
878 } 881 }
879 882