Skip to content

Commit

Permalink
Fixed searching words with underscore.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Apr 5, 2024
1 parent 19976f4 commit d0f5a50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/S2/Rose/Entity/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function valueToArray()
$content = str_replace(['«', '»', '', '', '', ''], '"', $content);
$content = str_replace(['---', '--', '', ''], '', $content);
$content = preg_replace('#,\\s+,#u', ',,', $content);
$content = preg_replace('#[^\\-\\p{L}0-9\\^\\.,\\(\\)";?!…:—]+#iu', ' ', $content);
$content = preg_replace('#[^\\-\\p{L}0-9^_.,()";?!…:—]+#iu', ' ', $content);
$content = preg_replace('#\\n+#', ' ', $content);
$content = preg_replace('#\\s+#u', ' ', $content);
$content = mb_strtolower($content);
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Rose/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ public function testFeatures(
$this->assertEquals('25', $img1->getHeight());
$this->assertEquals('Alternative text', $img1->getAlt());

// Query 12
$resultSet12 = $finder->find(new Query('long_word_with_underscores'));
$this->assertCount(1, $resultSet12->getItems());
$this->assertEquals('Some sentence with <b>long_word_with_underscores</b>.', $resultSet12->getItems()[0]->getSnippet());

// Empty result
$this->assertCount(0, $finder->find(new Query('..'))->getItems());
$this->assertCount(0, $finder->find(new Query('...'))->getItems());
Expand Down Expand Up @@ -424,7 +429,7 @@ public function indexableProvider()
,
(new Indexable('id_1', 'Another instance', 'The same id but another instance. Word "content" is present here. Twice: content. Delimiters must be $...$ or \[...\]', 20))
,
(new Indexable('id_4', 'Another instance', 'Nothing is here but images: <img src="1.jpg" width="10" height="15"> <img src="2%203.jpg" width="20" height="25" alt="Alternative text" />', 20))
(new Indexable('id_4', 'Another instance', 'Some sentence with long_word_with_underscores. Nothing is here but images: <img src="1.jpg" width="10" height="15"> <img src="2%203.jpg" width="20" height="25" alt="Alternative text" />', 20))
,
];

Expand Down

0 comments on commit d0f5a50

Please sign in to comment.