An introduction to using and paging coreseek

  • 2020-06-15 07:59:51
  • OfStack

It's really hard to find the amount of data when coreseek does paging. I thought he was going to give me a method or something to get, but it wasn't.
The first thing to understand is:
num_matches: Number of results currently returned, < = limit setting value.
max_matches: Maximum number of results returned, default is 1000, users can only see 1000 search results. This is set in ES10en_mysql.conf.
total_found: Total results. The total number of documents in the index that meet the query criteria. This is in the array of results returned from your query. Of course, you must set it before query: $this- > sc- > SetArrayResult(true);
total: Returns the maximum number of results, depending on the max_matches value and total_found value. If the number of total_found exceeds max_matches, then total = max_matches; otherwise, total = total_found. This is also in the array of results returned from your query. Of course, you must set it before query: $this- > sc- > SetArrayResult(true);
That way, once you know the properties, you can do pagination.

We should use total in the return value for the total number of pages. Although this does not represent the true return value (if the return value is greater than max_matches, which is 1000, if the true return is 2500, you will only get 1000).
The code is:

$this->sc->SetServer("127.0.0.1",9312);
  $this->sc->SetArrayResult(true);
  $this->sc->SetLimits($start,$page);
// If you need to search for the contents of a specified full-text field, you can use the extended matching pattern: 
  $this->sc->SetMatchMode(SPH_MATCH_ANY); 
$res = $this->sc->Query($where,"main");
$count = $res['total'];

This ¥count is the total number of pages we want.
The rest of the pagination is based on style and data structure, not the same, and pagination is fundamental, so I won't go into the details of pagination here. I'm just talking about the value of this aggregate data. Because a lot of people take count($res['matches']), but this is a paginated return, and you only get 10 or 20 or something. Well, that's funny.

Related articles: