Skip to content

Commit

Permalink
The number of documents is not the same in different Solr versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Feb 21, 2025
1 parent c966beb commit c3ee145
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Plugin/search_api/backend/SearchApiSolrBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -4842,7 +4842,7 @@ protected function doDocumentCounts(Endpoint $endpoint): array {
}
catch (\Exception $e) {
// For non drupal indexes we only use the implicit "count" aggregation.
// Therefore we need one random facet. The only field we can be 99% sure
// Therefore, we need one random facet. The only field we can be 99% sure
// that it exists in any index is _version_. max(_version_) should be the
// most minimalistic facet we can think of.
$query = $connector->getSelectQuery()->setRows(1);
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/StreamingExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ public function _checkpoint($checkpoint) {
* a very high fixed value makes no sense as this would waste memory in Solr
* Cloud and might lead to out of memory exceptions. The numbers are prepared
* via search_api_solr_cron(). If the cron hasn't run yet the function return
* 1024 as fallback.
* 512 as fallback.
*
* @return int
* Integer of the row limit.
Expand Down
10 changes: 6 additions & 4 deletions tests/src/Kernel/SearchApiSolrTechproductsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ public function testStreamingExpressions() {
$query = $queryHelper->createQuery($index);
$exp = $queryHelper->getStreamingExpressionBuilder($query);

$this->assertEquals(64, $exp->getSearchAllRows());
// The number of documents is not the same in different Solr versions, 32 or
// 31.
$this->assertGreaterThanOrEqual(31, $exp->getSearchAllRows());

$search_expression = $exp->_search_all(
'q="*:*"',
Expand All @@ -139,7 +141,7 @@ public function testStreamingExpressions() {

$queryHelper->setStreamingExpression($query, $search_expression);
$results = $query->execute();
$this->assertEquals(32, $results->getResultCount());
$this->assertGreaterThanOrEqual(31, $results->getResultCount());

$topic_expression = $exp->_topic_all(
$exp->_checkpoint('all_products'),
Expand All @@ -150,7 +152,7 @@ public function testStreamingExpressions() {
$query = $queryHelper->createQuery($index);
$queryHelper->setStreamingExpression($query, $topic_expression);
$results = $query->execute();
$this->assertEquals(32, $results->getResultCount());
$this->assertGreaterThanOrEqual(31, $results->getResultCount());

$query = $queryHelper->createQuery($index);
$queryHelper->setStreamingExpression($query, $topic_expression);
Expand All @@ -171,7 +173,7 @@ public function testStreamingExpressions() {
$query = $queryHelper->createQuery($index);
$queryHelper->setStreamingExpression($query, $topic_expression);
$results = $query->execute();
$this->assertEquals(12, $results->getResultCount());
$this->assertGreaterThanOrEqual(11, $results->getResultCount());

$query = $queryHelper->createQuery($index);
$queryHelper->setStreamingExpression($query, $topic_expression);
Expand Down

0 comments on commit c3ee145

Please sign in to comment.