minor
#27440
Quick search: Search for phrases and terms with (Lucene) control characters does not work
Background
The search text you enter consists of terms. Terms are separated by spaces. There are two types of terms: words and phrases. A phrase consists of multiple words enclosed in double quotation marks. Control characters in the entered text are automatically escaped in the quick search and are therefore interpreted as part of the search text.
Problem
(1) If the search term contains a control character reserved by Lucene (e.g., "+" or "-"), no results are found: A search for the invoice number **FDR-2023-0002** returns no results, but should find the invoice.
(2) When searching for a phrase, all objects are always returned as search results, even though they do not contain the search text: A search for **"FDR-2023-0002"** returns just as many objects as a search for **"any string"**.
Test
- Start TL Demo
- Structures / Type Demo: Generate
- Rename object A0 to **xyz-abcz**
- Quick search for **xyz**: 1 match -> correct.
- Quick search for **bcz**: 1 result -> correct.
- Quick search for **xyz-abcz**: 0 hits -> incorrect, 1 expected.
- Quick search for **"xyz-abcz"**: N hits -> incorrect, 1 expected.
Findings so far
AbstractSearchCommand.getQueryConfiguration(String)
calls
Query.getFullTextQuery(String searchText, boolean isAnd, boolean exactMatch)
with the parameter
exactMatch = false
This adds a leading and trailing '*' character to the query. Is it possible that this extension is not interpreted correctly (=bug in Lucene)?
If you change the call to:
exactMatch=true
test cases 1, 3, and 4 above work, but 2 no longer does, because no substrings are found in that case.