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 terms position sorting NOT applied on REST "v1/search" and GraphQL "products" API calls #1660

Closed
rbayet opened this issue Jan 9, 2020 · 0 comments
Assignees
Labels

Comments

@rbayet
Copy link
Collaborator

rbayet commented Jan 9, 2020

Both REST "v1/search" and GraphQL "products" use Elasticsuite and correctly :

  • take into account the store context (either by URL or HTTP header)
  • apply search terms merchandising blacklisting of products
  • apply search optimizers

But the search_query.position / ASC sort order is never applied to the generated Elasticsearch query : search terms merchandiser positions are not applied.

Preconditions

Magento Version : 2.3.2

ElasticSuite Version : 2.8.2, 2.8.3, 2.8-x

Environment : Developer

Third party modules : N/A

Steps to reproduce

  1. On a Luma instance, search in frontend for the term "gym"
  2. Then go back to the admin in "Marketing / Search terms" and edit the "gym" search term
  3. Go the merchandiser screen, clear all positions, save and continue
  4. Pick 1 or 2 distinctive products located after the 10th position and pin them at the beginning
  5. Blacklist one of the products at the beginning of the results
  6. Save and continue, and check in frontend that the positions and the blacklisting are correctly applied
  7. Use a REST client (for instance Postman) or command line and build the call to rest/V1/search which search for "gym", while forcing a big page size. Here with 100 : http://domain.tld/rest/V1/search?searchCriteria[requestName]=quick_search_container&searchCriteria[filter_groups][0][filters][0][field]=search_term&searchCriteria[filter_groups][0][filters][0][value]=gym&searchCriteria[pageSize]=100&searchCriteria[currentPage]=1
  8. Use a GraphQL client (for instance GraphiQL) and perform a search with the "products" query on the http://domain.tld/graphql endpoint while forcing a big page size
{
  products(search: "gym", pageSize: 100, currentPage: 1) {
    total_count
    sort_fields {
      default
      options {
        label
        value
      }
    }
    items {
      id
      sku
      name
    }
  }
}

PS : Using a big page size is important. You need to specify a page size bigger than the amount of results because of an bug in the native Magento\CatalogGraphQL module.
Searching for "gym" in a Luma should match less than 30 products, so searching with a pageSize of 100 is a safe approach.

Expected result

  1. Both with REST v1/search and GraphQL, the relative order of search results should be the same as in the frontend

Actual result

  1. The blacklisted products are correctly missing from the results, but the specific pinned positions are ignored
  2. In both cases, inspecting the queries in the debug log shows that the "bool/must_not/search_query.is_blacklisted" query filter is applied, but not the "search_query.position/asc" sort order.
@rbayet rbayet added the bug label Jan 9, 2020
@rbayet rbayet changed the title Search terms position sorting applied on REST "v1/search" and GraphQL "products" API calls Search terms position sorting NOT applied on REST "v1/search" and GraphQL "products" API calls Jan 14, 2020
@rbayet rbayet assigned rbayet and unassigned androshchuk Jan 16, 2020
@rbayet rbayet closed this as completed in e14d739 Jan 17, 2020
rbayet added a commit that referenced this issue Jan 17, 2020
…h_terms_positioning

Fixes #1660 Search terms positions sorting on REST and GraphQL
rbayet added a commit to rbayet/elasticsuite that referenced this issue Jan 17, 2020
romainruaud added a commit that referenced this issue Jan 17, 2020
Fixes #1660 Search terms positions... Code quality update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants