yii\elasticsearch\Query::from PHP Method

from() public method

Sets the index and type to retrieve documents from.
See also: 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.
    public function from($index, $type = null)
    {
        $this->index = $index;
        $this->type = $type;
        return $this;
    }

Usage Example

 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']);
 }
All Usage Examples Of yii\elasticsearch\Query::from