from() 공개 메소드

Sets the index and type to retrieve documents from.
또한 보기: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-multi-index-type
public from ( string | array $index, string | array $type = null )
$index string | array The index to retrieve data from. This can be a string representing a single index or a an array of multiple indexes. If this is `null` it means that all indexes are being queried.
$type string | array The type to retrieve data from. This can be a string representing a single type or a an array of multiple types. If this is `null` it means that all types are being queried.
예제 #1
1
 public function testFuzzySearch()
 {
     $this->prepareDbData();
     $queryParts = ["fuzzy_like_this" => ["fields" => ["title"], "like_text" => "Similar to YII", "max_query_terms" => 4]];
     $query = new Query();
     $query->from('yiitest', 'article');
     $query->query = $queryParts;
     $result = $query->search($this->getConnection());
     $this->assertEquals(3, $result['hits']['total']);
 }
예제 #2
0
 public function testColumn()
 {
     $query = new Query();
     $query->from('yiitest', 'user');
     $result = $query->orderBy(['name' => SORT_ASC])->column('name', $this->getConnection());
     $this->assertEquals(['user1', 'user2', 'user3', 'user4'], $result);
     $result = $query->column('noname', $this->getConnection());
     $this->assertEquals([null, null, null, null], $result);
     $result = $query->where(['name' => 'user5'])->scalar('name', $this->getConnection());
     $this->assertNull($result);
 }