Merge branch 'master' into serp-redesign

This commit is contained in:
Viktor Lofgren 2025-01-05 23:33:35 +01:00
commit 8dde502cc9
2 changed files with 22 additions and 0 deletions

View File

@ -71,6 +71,17 @@ public class QueryFactory {
String[] parts = StringUtils.split(str, '_');
// Trim down tokens to match the behavior of the tokenizer used in indexing
for (int i = 0; i < parts.length; i++) {
String part = parts[i];
if (part.endsWith("'s") && part.length() > 2) {
part = part.substring(0, part.length()-2);
}
parts[i] = part;
}
if (parts.length > 1) {
// Require that the terms appear in sequence
queryBuilder.phraseConstraint(SearchPhraseConstraint.mandatory(parts));

View File

@ -208,6 +208,17 @@ public class QueryFactoryTest {
System.out.println(subquery);
}
@Test
public void testQuotedApostrophe() {
var subquery = parseAndGetSpecs("\"bob's cars\"");
System.out.println(subquery);
Assertions.assertTrue(subquery.query.compiledQuery.contains(" bob "));
Assertions.assertFalse(subquery.query.compiledQuery.contains(" bob's "));
Assertions.assertEquals("\"bob's cars\"", subquery.humanQuery);
}
@Test
public void testExpansion9() {
var subquery = parseAndGetSpecs("pie recipe");