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

Pagination is broken - only a single page link is displayed at the bottom #4

Open
212223 opened this issue Mar 25, 2022 · 3 comments
Open

Comments

@212223
Copy link
Contributor

212223 commented Mar 25, 2022

There is always only one page having max 3 results displayed with no other available at the bottom as a pagination even when no filters are applied.

1

@212223 212223 mentioned this issue Mar 25, 2022
@212223
Copy link
Contributor Author

212223 commented Apr 8, 2022

Problem solved by adding ['value'] to this line:

$this->total = (int)($this->rawResponse['hits']['total'] ?? 0);]

so it should look like this:

$this->total = (int)($this->rawResponse['hits']['total']['value'] ?? 0);

because the $rawResponse for the request without any filters on the Elasticsearch v7.17.1 is:

array (
  'took' => 4,
  'timed_out' => false,
  '_shards' => 
  array (
    'total' => 1,
    'successful' => 1,
    'skipped' => 0,
    'failed' => 0,
  ),
  'hits' => 
  array (
    'total' => 
    array (
      'value' => 39,
      'relation' => 'eq',
    ),
    'max_score' => 101.0,
    'hits' => 
    array (
      0 => 
      array (
        '_index' => 'cars',
        '_type' => '_doc',
        '_id' => '35',
        '_score' => 101.0,
        '_source' => 
        array (
          'producer' => 'Dodge',
          'model' => 'Viper GTS',
          'picture' => 'dodge-viper-gts.jpg',
          'production_year' => 1997,
          'colors' => 
          array (
            0 => 'blue',
            1 => 'white',
          ),
          'service_ids' => 
          array (
            0 => 5,
            1 => 6,
            2 => 8,
          ),
        ),
      ),
      1 => 
      array (
        '_index' => 'cars',
        '_type' => '_doc',
        '_id' => '36',
        '_score' => 101.0,
        '_source' => 
        array (
          'producer' => 'Dodge',
          'model' => 'Viper SRT10 Roadster',
          'picture' => 'dodge-viper-srt10-roadster.jpg',
          'production_year' => 2017,
          'colors' => 
          array (
            0 => 'yellow',
            1 => 'black',
          ),
          'service_ids' => 
          array (
            0 => 1,
            1 => 2,
            2 => 3,
            3 => 4,
            4 => 5,
            5 => 6,
            6 => 7,
            7 => 8,
          ),
        ),
      ),
      2 => 
      array (
        '_index' => 'cars',
        '_type' => '_doc',
        '_id' => '37',
        '_score' => 101.0,
        '_source' => 
        array (
          'producer' => 'Dodge',
          'model' => 'Challenger',
          'picture' => 'dodge-challenger.jpg',
          'production_year' => 2015,
          'colors' => 
          array (
            0 => 'green',
            1 => 'black',
          ),
          'service_ids' => 
          array (
            0 => 8,
            1 => 5,
            2 => 4,
          ),
        ),
      ),
    ),
  ),
)

@lrynek
Copy link
Owner

lrynek commented Apr 8, 2022

Problem solved by adding ['value'] to this line:

$this->total = (int)($this->rawResponse['hits']['total'] ?? 0);]

so it should look like this:

$this->total = (int)($this->rawResponse['hits']['total']['value'] ?? 0);

@212223 thank you! I know why I couldn't reproduce that locally - I have Elasticsearch 6.6 version installed on the local system 😉

// I will try to review it and fix this in upcoming week 👍

@212223
Copy link
Contributor Author

212223 commented Apr 12, 2022

@lrynek You are welcome. If you have Elasticsearch 6.6 that would explain why there was needed a workaround for that issue: The mapping definition cannot be nested on Elasticsearch 7.17.1

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

No branches or pull requests

2 participants