Esempio n. 1
0
 /**
  * @{inheritDoc}
  */
 public function index($object_type, $object_id, $data)
 {
     $data['id'] = $object_type . '_' . $object_id;
     $data['type'] = $object_type;
     $article = new \phpbb\titania\search\document();
     // Set some defaults
     $data = array_merge(array('access_level' => access::PUBLIC_LEVEL, 'approved' => true, 'reported' => false), $data);
     $article->setState($data);
     // Run the update routine instead of the index, this way we should not ever run into issues with duplication
     $this->client->update($article);
 }
Esempio n. 2
0
 public function testUpdateDocument1()
 {
     $a = new Article(null, 'Test Article', 'This is an article to test', 'the body of the article', time());
     $session = new ezcSearchSession($this->backend, new ezcSearchXmlManager($this->testFilesDir));
     $session->index($a);
     $this->backend->sendRawPostCommand('update', array('wt' => 'json'), '<commit/>');
     $q = $session->createFindQuery('Article');
     $q->where($q->eq('title', 'Article'));
     $r = $session->find($q);
     self::assertEquals(1, $r->resultCount);
     self::assertEquals('Test Article', $r->documents[$a->id]->document->title);
     self::assertEquals('This is an article to test', $r->documents[$a->id]->document->summary);
     $a->title = "New Title";
     $session->update($a);
     $q = $session->createFindQuery('Article');
     $q->where($q->eq('title', 'Title'));
     $r = $session->find($q);
     self::assertEquals(1, $r->resultCount);
     self::assertEquals('New Title', $r->documents[$a->id]->document->title);
     self::assertEquals('This is an article to test', $r->documents[$a->id]->document->summary);
 }
Esempio n. 3
0
 public function testUpdateDocument2()
 {
     $session = new ezcSearchSession($this->backend, new ezcSearchXmlManager($this->testFilesDir));
     $session->index(new Document(1, 'Test'));
     $session->update(new Document(1, 'Something else'));
     $session->index(new Document(2, 'Test'));
     $queryBuilder = new ezcSearchQueryBuilder();
     $query = $session->createFindQuery('Document');
     $queryBuilder->parseSearchQuery($query, 'Test', array('title', 'body'));
     $r = $session->find($query);
     self::assertEquals(2, $r->documents[2]->document->id);
     self::assertEquals('Test', $r->documents[2]->document->title);
     self::assertEquals(1, $r->resultCount);
 }