mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Search Index: Fixed SQL error when indexing large pages
Due to hitting statement placeholder limits (typically 65k) when inserting index terms for single page. Added test to cover. Also added skipped tests for tests we don't always want to run. For #5322
This commit is contained in:
@ -6,6 +6,7 @@ use BookStack\Activity\Models\Tag;
|
||||
use BookStack\Entities\Models\Book;
|
||||
use BookStack\Entities\Models\Bookshelf;
|
||||
use BookStack\Entities\Models\Chapter;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EntitySearchTest extends TestCase
|
||||
@ -477,6 +478,25 @@ class EntitySearchTest extends TestCase
|
||||
$this->assertEquals(2, $scoreByTerm->get('TermG'));
|
||||
}
|
||||
|
||||
public function test_indexing_works_as_expected_for_page_with_lots_of_terms()
|
||||
{
|
||||
$this->markTestSkipped('Time consuming test');
|
||||
|
||||
$count = 100000;
|
||||
$text = '';
|
||||
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_#';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$text .= substr(str_shuffle($chars), 0, 5) . ' ';
|
||||
}
|
||||
|
||||
$page = $this->entities->newPage(['name' => 'Test page A', 'html' => '<p>' . $text . '</p>']);
|
||||
|
||||
$termCount = $page->searchTerms()->count();
|
||||
|
||||
// Expect at least 90% unique rate
|
||||
$this->assertGreaterThan($count * 0.9, $termCount);
|
||||
}
|
||||
|
||||
public function test_name_and_content_terms_are_merged_to_single_score()
|
||||
{
|
||||
$page = $this->entities->newPage(['name' => 'TermA', 'html' => '
|
||||
|
Reference in New Issue
Block a user