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

Optimizer: category preview is (still) not working #1308

Closed
FredRaym opened this issue Feb 18, 2019 · 5 comments
Closed

Optimizer: category preview is (still) not working #1308

FredRaym opened this issue Feb 18, 2019 · 5 comments
Assignees
Labels

Comments

@FredRaym
Copy link

Hi,

Perhaps duplicates the now closed issue #1092 ...

Once the optimizer is well configured, the category preview displays loader but the preview area reamins empty. It works fine with the search preview

XHR log :
?isAjax=true => 200
Response :
{base_products: [], optimized_products: [], size: 0}
base_products: []
optimized_products: []
size: 0

Magento Version : Magento commerce 2.2.5
ElasticSuite Version : 2.6.3
Environment : Dev & Prod modes

Regards

2019-02-18-13_45_17

@rbayet
Copy link
Collaborator

rbayet commented Feb 20, 2019

Hello @FredRaym,

Cannot reproduce this issue on EE 2.2.5 and with ElasticSuite 2.6.3 or later 2.6.x versions.
Could not either reproduce on your specific project (dev) environment.

Was it occuring in an environment setup in production mode ?

Regards,
Richard.

@FredRaym
Copy link
Author

Yes it is, Production mode.

Regards

@rbayet rbayet assigned rbayet and unassigned FredRaym Feb 21, 2019
@rbayet
Copy link
Collaborator

rbayet commented Feb 21, 2019

Confirmed on EE 2.2.5 + ElasticSuite 2.6.3 + Luma in production mode
Updated Still present on ElasticSuite 2.6.6

@rbayet
Copy link
Collaborator

rbayet commented Feb 21, 2019

For reference, queries being sent to ES

developer mode
{
  "size": 20,
  "sort": [
    {
      "category.position": {
        "order": "asc",
        "missing": "_last",
        "unmapped_type": "keyword",
        "nested_path": "category",
        "mode": "min",
        "nested_filter": {
          "terms": {
            "category.category_id": [
              "34"
            ],
            "boost": 1
          }
        }
      }
    },
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "entity_id": {
        "order": "desc",
        "missing": "_first",
        "unmapped_type": "keyword"
      }
    }
  ],
  "from": 0,
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "visibility": [
                  2,
                  4
                ],
                "boost": 1
              }
            },
            {
              "terms": {
                "stock.is_in_stock": [
                  true
                ],
                "boost": 1
              }
            },
            {
              "nested": {
                "path": "category",
                "score_mode": "none",
                "query": {
                  "bool": {
                    "must": [
                      {
                        "bool": {
                          "must_not": [
                            {
                              "term": {
                                "category.is_virtual": {
                                  "value": true,
                                  "boost": 1
                                }
                              }
                            }
                          ],
                          "boost": 1
                        }
                      },
                      {
                        "terms": {
                          "category.category_id": [
                            "34"
                          ],
                          "boost": 1
                        }
                      }
                    ],
                    "must_not": [],
                    "should": [],
                    "boost": 1
                  }
                },
                "boost": 1
              }
            }
          ],
          "must_not": [],
          "should": [],
          "boost": 1
        }
      },
      "boost": 1
    }
  }
}
production mode
{
  "size": 20,
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "entity_id": {
        "order": "desc",
        "missing": "_first",
        "unmapped_type": "keyword"
      }
    }
  ],
  "from": 0,
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "visibility": [
                  3,
                  4
                ],
                "boost": 1
              }
            },
            {
              "terms": {
                "stock.is_in_stock": [
                  true
                ],
                "boost": 1
              }
            }
          ],
          "must_not": [],
          "should": [],
          "boost": 1
        }
      },
      "must": {
        "bool": {
          "must": {
            "multi_match": {
              "query": "",
              "fields": [
                "search.whitespace^1",
                "name.whitespace^5"
              ],
              "minimum_should_match": "100%",
              "tie_breaker": 1,
              "boost": 1,
              "type": "best_fields"
            }
          },
          "boost": 1
        }
      },
      "boost": 1
    }
  }
}

In production mode, it looks like there is a fallback on the quick search container

  • there is no longer a sort on category position
  • the category path query filter is missing
  • the visibility filter is the one pertaining to the search

@rbayet
Copy link
Collaborator

rbayet commented Feb 21, 2019

This is due to the following code in \Magento\Framework\ObjectManager\Factory\Compiled::create which has a problem with :

  • providing a `$queryText = null'
  • while \Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview::__construct has default value for $queryText of (empty string)
        } elseif ($args !== null) {
            /**
             * Case 2: arguments retrieved from pre-compiled DI cache
             *
             * Argument key meanings:
             *
             * _i_: shared instance of a class or interface
             * _ins_: non-shared instance of a class or interface
             * _v_: non-array literal value
             * _vac_: array, may be nested and contain other types of keys listed here (objects, array, nulls, etc)
             * _vn_: null value
             * _a_: value to be taken from named environment variable
             * _d_: default value in case environment variable specified by _a_ does not exist
             */
            foreach ($args as $key => &$argument) {
                if (isset($arguments[$key])) {
                    $argument = $arguments[$key];
                } elseif (isset($argument['_i_'])) {
                    $argument = $this->get($argument['_i_']);
                } elseif (isset($argument['_ins_'])) {
                    $argument = $this->create($argument['_ins_']);
                } elseif (isset($argument['_v_'])) {
                    $argument = $argument['_v_'];
                } elseif (isset($argument['_vac_'])) {
                    $argument = $argument['_vac_'];
                    $this->parseArray($argument);
                } elseif (isset($argument['_vn_'])) {
                    $argument = null;
                } elseif (isset($argument['_a_'])) {
                    if (isset($this->globalArguments[$argument['_a_']])) {
                        $argument = $this->globalArguments[$argument['_a_']];
                    } else {
                        $argument = $argument['_d_'];
                    }
                }
            }
            $args = array_values($args);

where $args contains the constructor arguments description and $arguments contains the runtime arguments.

$args['queryText'] contains ['_v_'] = '' and $arguments['queryText'] contains null.

Hence if (isset($arguments[$key])) { fails, so which is applied is

                } elseif (isset($argument['_v_'])) {
                    $argument = $argument['_v_'];

The $queryText = null argument is replaced by $queryText = '' which leads to a bad turn in \Smile\ElasticsuiteCatalogOptimizer\Model\Optimizer\Preview\RequestBuilder::getSearchRequestParams :

        if ($queryText !== null) {
            $query = $this->searchQueryBuilder->getFullTextQuery($containerConfig, $queryText);
        } elseif ($category !== null) {
            $query      = $this->categoryQueryBuilder->getCategorySearchQuery($containerConfig, $category);
            $sortOrders = $this->categoryQueryBuilder->getCategorySortOrders($category);
        }

rbayet added a commit to rbayet/elasticsuite that referenced this issue Feb 21, 2019
romainruaud added a commit that referenced this issue Feb 25, 2019
…iew-production-mode

Fixes #1308 Optimizer category preview not working
romainruaud added a commit that referenced this issue Feb 25, 2019
…iew-production-mode-2.3.x

Fixes #1308 Optimizer category preview not working (M2 2.3.x)
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

3 participants