A
A
alex_maldinsky2018-09-28 20:54:28
Sphinx
alex_maldinsky, 2018-09-28 20:54:28

Sphinx and Yii2, how to set limit correctly?

Please tell me I have 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 doing the right thing with sphinx? I pass it a search request, get an array of id and select them.
  2. How to work with limit in sphinx? Returns only 20 records... Get the current page and count based on the number of items on the page?
  3. Or with sphinx I need to get not only id? and full volume of the data and to transfer them in DataProvider?

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex_maldinsky, 2018-09-28
@alex_maldinsky

The fact is that in the view I work with the news object and use its methods, what should I do?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question