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

Undefined index: tokens on line 227 module-elasticsuite-thesaurus/Model/Index.php #1165

Closed
jsterling opened this issue Oct 31, 2018 · 5 comments

Comments

@jsterling
Copy link

Preconditions

Magento Version : CE 2.2.6

ElasticSuite Version : 2.6

Environment : Production

Third party modules :

Steps to reproduce

  1. perform a search (not selecting an option from autocomplete)

Expected result

  1. Search results displayed

Actual result

  1. catalogsearch/result page throws a 500 error, log shows

Notice: Undefined index: tokens in [webroot]/app\/vendor\/smile\/elasticsuite\/src\/module-elasticsuite-thesaurus\/Model\/Index.php on line 227"

This is the line foreach ($analysis['tokens'] as $token) {

This happens for multiple users, from multiple different browsers including 'private browsing', however it only happens occasionally (maybe 1 in 10 searches). We're using Elastic Cloud - no errors or warnings shown.

@jsterling
Copy link
Author

A very crude if(!isset($analysis['tokens'])) $analysis['tokens'] = array(); just before line 227 seems to solve this

@romainruaud
Copy link
Collaborator

Well, seems kinda strange especially when I see the line just above this one :

        try {
            $analysis = $this->client->analyze(
                ['index' => $indexName, 'body' => ['text' => $queryText, 'analyzer' => $type]]
            );
        } catch (\Exception $e) {
            $analysis = ['tokens' => []];
        }

This would mean that we had a successful response of $client->analyze but without any tokens on it...

Are you able to reproduce this one easily ? I'm curious about what is actually being returned in the $analysis variable in the failing case.

@jsterling
Copy link
Author

It was happening on virtually every search request until I added my change. We saw the same result whether or not there were Thesaurus entries.

I should be able to reproduce easily, if you can let me know the best format / way to send you a log or print and what you'd want to see?

@romainruaud
Copy link
Collaborator

I received your log, but I'm more interested by a print_r($analysis) just before the line which fails, to see what have been answered by the engine for the precedent call.

In any cases, PR #1176 will fix the issue and is scheduled to be released on monday with the new minor version.

@romainruaud
Copy link
Collaborator

Fixed by PR #1176 that will be part of next minor release.

I close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants