Detail
#27440
Quick search: Search for phrases and terms with (Lucene) control characters does not work
Background
The entered search text consists of terms. Terms are separated by spaces. There are 2 types of terms: Words and phrases. A phrase is several words in double quotes. Control characters in the entered text are automatically escaped in the quick search, and are thus interpreted as part of the searched text.
Problem
(1) If the searched term contains a control character reserved by Lucene (e.g. "+" or "-"), no hits are found: Searching for invoice number **FDR-2023-0002** returns no hits, but should find the invoice.
(2) Searching for a phrase always returns all objects as search results, even though they do not contain the searched text: Searching for **"FDR-2023-0002"** returns all objects in the same way as searching for **"any string "**.
Test
- Start TL Demo
- Structures / Type demo: Generate
- Rename object A0 to **xyz-abcz**.
- Quick search for **xyz**: 1 hit -> correct.
- Quick search for **bcz**: 1 hit -> 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)
gets
Query.getFullTextQuery(String searchText, boolean isAnd, boolean exactMatch)
with the parameter
exactMatch = false
This extends the query with a leading and closing '*' character. Maybe this extension is not interpreted correctly (=bug in Lucene)?
If you change the call:
exactMatch=true
the above test cases 1, 3 and 4 but 2 do not work anymore, because then no substrings are found.