Please tell me there is the following code:

public function search() { $this->load($this->searchParams); $query = new Query(); $items = $query->from('news') ->match($this->query) ->orderBy(['date_added' => SORT_DESC]) ->all(); $items = array_column($items,'id'); $query = News::find() ->where(['in', 'id', $items]); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'sort' => false, 'pagination' => [ 'pageSize' => 15 ] ]); return $dataProvider; } 
  1. Am I working with sphinx right? I give him a search query, get an array of id and do a selection of them.
  2. How to work with limit with sphinx? Returns only 20 records ... Get the current page and count based on the number of elements on the page?
  3. Or with sphinx I need to get not only id? and full volume of data and transfer them to DataProvider?

Thank you in advance.

    1 answer 1

    1) It is better to set limits and offsets for a query in sphinx, but if the display speed suits you and does not need to be optimized, then you can leave it.

    2) You can set -> limit (-1) or -> addOptions (['max_matches' => -1]), then it will return all records. But there is a nuance of them can not be more than 65535.

    3) You can add data to Sphinx and display it without making a separate query to the database to speed up (optimize) the output, but you should not forget that Sphinx is a search engine and not a replacement for the current database. And if the speed of data display in your version suits the customer, then leave it as it is.