Introduction to Using Coreseek and paging (GO)

Source: Internet
Author: User

It's really not easy to find the total amount of data when Coreseek paging. Thought he would give a method (function) something to get, but the result is not.
First you need to know:
Num_matches:
The number of results currently returned, <= limit setting value.
max_matches: The maximum number of results returned, default is 1000, and users can see up to 1000 search results. This is set in NF.
Total_found: Total number of results. The total number of documents in the index that satisfy the query criteria. This is in the array of the returned results of your query. Of course, if you have to set it before query: $this->sc->setarrayresult (TRUE);
Total: Returns the maximum number of results, depending on the max_matches value and the Total_found value. If the number of total_found is more than max_matches, total = Max_matches, otherwise, all = Total_found. This is also in the array of the returned results of your query. Of course the premise is that you must set before query: $this->sc->setarrayresult (TRUE);
This way, you will be able to do pagination after you have learned these properties.

We should use total in the return value to do the paging data. Although this does not represent the true return value (when the return value is greater than max_matches, which is 1000, such as true returns 2500, you can only get 1000).
The code is:

Copy the code code as follows:

$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 whole-text segment, you can use the extended match pattern:
$this->sc->setmatchmode (Sph_match_any);
$res = $this->sc->query ($where, "main");
$count = $res [' Total '];


This ¥count is the total data we need for paging.
Other follow-up how pagination is done in style and data structure, can not be the same, and pagination is the basis of things, so here is no longer to say more detailed pagination problem. I'll just discuss the value of the total data here. Because a lot of people take count ($res [' matches ']) value, but this is the result of paging back, you can only get 10, or 20 or other values. Oh, that's funny.

Introduction to Using Coreseek and paging (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.