Ejemplo n.º 1
0
 public function testMultiGet()
 {
     $type1 = new CM_Elasticsearch_Type_Mock1();
     $type2 = new CM_Elasticsearch_Type_Mock2();
     $source = new CM_PagingSource_Elasticsearch(array($type1, $type2), new CM_Elasticsearch_Query());
     $this->assertSame(0, $source->getCount());
     $id1 = $type1->createEntry('foo');
     $this->assertSame(1, $source->getCount());
     $id2 = $type2->createEntry(1);
     $this->assertSame(2, $source->getCount());
     $this->assertContainsAll(array(array('id' => (string) $id1, 'type' => 'index_1'), array('id' => (string) $id2, 'type' => 'index_2')), $source->getItems());
     $type3 = new CM_Elasticsearch_Type_Mock3();
     $source = new CM_PagingSource_Elasticsearch(array($type1, $type2, $type3), new CM_Elasticsearch_Query(), array('price'));
     $id3 = $type3->createEntry(5);
     $this->assertSame(3, $source->getCount());
     $this->assertContainsAll(array(array('id' => (string) $id1, 'type' => 'index_1'), array('id' => (string) $id2, 'type' => 'index_2'), array('id' => (string) $id3, 'type' => 'index_3', 'price' => 5)), $source->getItems());
 }
Ejemplo n.º 2
0
 public function testUpdateItemWithJob()
 {
     $query = new CM_Elasticsearch_Query();
     $query->queryMatchMulti(array('name'), 'foo');
     $source = new CM_PagingSource_Elasticsearch($this->_type, $query);
     $this->assertSame(0, $source->getCount());
     $id1 = $this->_type->createEntry('foo');
     $id2 = $this->_type->createEntry('foo bar');
     $this->assertSame(2, $source->getCount());
     $this->assertEquals(array($id1, $id2), $source->getItems());
     CM_Db_Db::update('index_mock', array('name' => 'bar'), array('id' => $id2));
     $this->_type->updateItemWithJob(array('id' => $id2));
     $this->assertSame(1, $source->getCount());
     $this->assertEquals(array($id1), $source->getItems());
 }
Ejemplo n.º 3
0
 function __construct(CM_Elasticsearch_Query $query)
 {
     parent::__construct(new CM_Elasticsearch_Type_Location(), $query, array('level', 'id'));
 }
Ejemplo n.º 4
0
 function __construct(CM_Elasticsearch_Query $query)
 {
     $client = CM_Service_Manager::getInstance()->getElasticsearch()->getClient();
     parent::__construct(new CM_Elasticsearch_Type_Location($client), $query, array('level', 'id'));
 }