Ejemplo n.º 1
0
 /**
  * Initialize a DocumentIndex with all documents stored in the DocumentStore
  * @param DocumentIndex $index Search index to initialize
  * @return DocumentIndex initialized with documents form the DocumentStore
  */
 public function buildIndex(DocumentIndex $index)
 {
     foreach ($this->documents as $document) {
         $index->addDocument($document);
     }
     return $index;
 }
 /**
  * Initialize a DocumentIndex with all documents stored in the DocumentStore
  * @param DocumentIndex $index Search index to initialize
  * @return DocumentIndex initialized with documents form the DocumentStore
  */
 public function buildIndex(DocumentIndex $index)
 {
     $cursor = $this->documents->find();
     foreach ($cursor as $result) {
         $document = new Document($result['title'], $result['content']);
         $document->id = $result['id'];
         $document->tokens = $result['tokens'];
         $index->addDocument($document);
     }
     return $index;
 }
Ejemplo n.º 3
0
 /**
  * Initialize a DocumentIndex with all documents stored in the DocumentStore
  * @param DocumentIndex $index Search index to initialize
  * @return DocumentIndex initialized with documents form the DocumentStore
  */
 public function buildIndex(DocumentIndex $index)
 {
     $query = "SELECT id, title, content FROM " . $this->table;
     $statement = $this->database->prepare($query);
     $statement->execute();
     $data = $statement->fetchAll();
     foreach ($data as $result) {
         $document = $this->buildDocument($result['id'], $result['title'], $result['content']);
         $index->addDocument($document);
     }
     $statement->closeCursor();
     return $index;
 }