fix(search): drop the quotes around a quoted free-text phrase
A bare quoted phrase such as "New York" was kept as a free-text term with its quotes, which no file name, tag or place ever contains, so it matched nothing. It is now one term without its quotes; a malformed prefixed token still keeps its original text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011xpLSeYKKHX6o16jzYLgZv
This commit is contained in:
@@ -71,9 +71,11 @@ public final class SearchQueryParser {
|
||||
if (prefixed != null) {
|
||||
filters.add(prefixed);
|
||||
} else {
|
||||
// The original text, prefix (and quotes) included — a malformed "r:abc" still searches for
|
||||
// literally "r:abc" rather than silently dropping it or losing the prefix a user did type.
|
||||
freeTextTerms.add(matcher.group(0));
|
||||
// A malformed prefixed token keeps its original text, prefix (and quotes) included — "r:abc"
|
||||
// still searches for literally "r:abc" rather than silently dropping it or losing the prefix a
|
||||
// user did type. A bare quoted phrase ("New York") is one term, without its quotes, which no
|
||||
// file name, tag or place ever contains.
|
||||
freeTextTerms.add(prefixToken == null ? value : matcher.group(0));
|
||||
}
|
||||
}
|
||||
if (!freeTextTerms.isEmpty()) {
|
||||
|
||||
@@ -32,6 +32,13 @@ class SearchQueryParserTest {
|
||||
assertThat(filters).containsExactly(new FreeTextFilter(List.of("beach", "sunset")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aQuotedPhraseIsOneFreeTextTermWithoutItsQuotes() {
|
||||
List<IMediaFileFilter> filters = SearchQueryParser.parse("\"New York\" beach 'Le Gué'");
|
||||
|
||||
assertThat(filters).containsExactly(new FreeTextFilter(List.of("New York", "beach", "Le Gué")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ratingExactPlusAndMinusProduceTheMatchingComparison() {
|
||||
SoftAssertions.assertSoftly(softly -> {
|
||||
|
||||
Reference in New Issue
Block a user