Elasticsearch pagenation spillage


(Lorenzo Marcel) #1

I run this query with a php client:

$params["body"] = [
            "from" => $page,
            "query" => ["filtered" => ["filter" => ["bool" => [
                            "must" => [
                                ["term" => ["user" =>  $userId]],
                                ["term" => ["activitySeen" =>  false]]
                            ]
                        ]
                    ]
                ]
            ],
            "size" => 5,
        ];

I have a total of 3 documents that should be returned. Searching with $page = 0 returns 3 documents as expected.

However, searching with $page = 1 returns 2 documents and with $page =
2 returns 1 document and the search with $page = 3 returns 0 documents.

Does anybody know what might be the issue?

If I play with page sizes the spillage is still there: last
legitimate page of values is spilled on to the next page with one less
value!

I'm testing it either on one or two nodes with 3 primary and 1 replica shards. ES 1.7.0 and official PHP client.

Thanks.

I found the problem: the from is an offset and not page number!


(system) #2