Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search REST API returns wrong total_count #17295

Closed
mohamed-karam opened this issue Jul 31, 2018 · 16 comments
Closed

Search REST API returns wrong total_count #17295

mohamed-karam opened this issue Jul 31, 2018 · 16 comments
Assignees
Labels
Component: Framework/Api USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog Service Contracts use just Catalog Component: Search Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@mohamed-karam
Copy link

Preconditions

  1. Magento 2.2.2

Steps to reproduce

  1. Make a request to endpoint GET /V1/search and provide searchCriteria[pageSize].
  2. Repeat the previous point with searchCiteria[currentPage] = 2

Expected result

  1. You will get a response with number of items equals searchCriteria[pageSize] in the first time
  2. You will get a response with number of items <= searchCriteria[pageSize] in the second time
  3. The total_count is the same on both requests

Actual result

The value of total_count equals searchCriteria[pageSize] not the total count of the search result items.

@magento-engcom-team
Copy link
Contributor

Hi @mohamed-karam. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation.

@mohamed-karam do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jul 31, 2018
@ghost ghost self-assigned this Aug 1, 2018
@ghost ghost added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Progress: needs update labels Aug 1, 2018
@ghost
Copy link

ghost commented Aug 1, 2018

Hi @mohamed-karam I'm not able to reproduce this issue by following the steps you provided.
frame-03f

@ghost
Copy link

ghost commented Aug 1, 2018

@mohamed-karam you need to use together, like this-> &searchCriteria[current_page]=1&searchCriteria[page_size]=2

@mohamed-karam
Copy link
Author

I think I need to elaborate more.
This is the request I send
{{url}}/rest/V1/search?searchCriteria[pageSize]=10&searchCriteria[currentPage]=1&searchCriteria[requestName]=quick_search_container&searchCriteria[filterGroups][0][filters][0][field]=search_term&searchCriteria[filterGroups][0][filters][0][conditionType]=like&searchCriteria[filterGroups][0][filters][0][value]={search_query}

If this search query for example has 15 items, the total_count will equal 10 not the real value of the total count of all items which should be 15.

@ghost
Copy link

ghost commented Aug 1, 2018

@mohamed-karam in your case currentPage=1 pageSize=10, so if you have a 100 result items it be a ->
1 page have -> 10 item, second page have 10 items so you have 10 pages, total count always 10 items on page.

@mohamed-karam
Copy link
Author

That isn't what happens with other endpoints that have searchCriteria. For example if you call this endpoint
{{url}}/rest/V1/products?searchCriteria[pageSize]=10&searchCriteria[currentPage]=1&searchCriteria[filterGroups][0][filters][0][field]=category_id&searchCriteria[filterGroups][0][filters][0][value]=75&searchCriteria[filterGroups][0][filters][0][conditionType]=eq
The total_count value will be the count of all items that matches the searchCriteria not just 10.

@ghost ghost added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Search Component: Framework/Api USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog Service Contracts use just Catalog and removed Progress: needs update labels Aug 1, 2018
@ghost
Copy link

ghost commented Aug 1, 2018

@mohamed-karam , thank you for your report .
We've acknowledged the issue and added to our backlog.

@ghost ghost added the Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release label Aug 1, 2018
@ghost ghost removed their assignment Aug 1, 2018
@ktpl-prakash ktpl-prakash self-assigned this Aug 13, 2018
@ktpl-prakash ktpl-prakash removed their assignment Sep 10, 2018
@abdulmalik422
Copy link

@engcom-backlog-andrii Please Update? I Will also face this issue.

@ronak2ram ronak2ram self-assigned this Jan 12, 2019
@magento-engcom-team
Copy link
Contributor

Hi @ronak2ram. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@ronak2ram
Copy link
Member

@magento-engcom-team give me 2.3-develop instance
@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @ronak2ram. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @ronak2ram, here is your Magento instance.
Admin access: https://i-17295-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ronak2ram
Copy link
Member

Hello @magento-engcom-team
I can't find this issue in 2.3-develop instance.

screenshot from 2019-01-12 12-21-22
screenshot from 2019-01-12 12-20-52

@abdulmalik422
Copy link

abdulmalik422 commented Jan 12, 2019 via email

@ronak2ram
Copy link
Member

ronak2ram commented Jan 12, 2019

@abdulmalik422 You right there is an issue. Let me try to find a solution

@magento-engcom-team
Copy link
Contributor

Hi @mohamed-karam. Thank you for your report.
The issue has been fixed in #21713 by @ronak2ram in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/Api USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog Service Contracts use just Catalog Component: Search Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants