Author: solbrig.harold
Description:
Patch for proposed query search enhancement
The attached patch is one that we have been using locally. It implements the following
- It makes _text fields queryable (which they aren’t at the moment).
- It changes wild card searches to case insensitive. (If this has backwards compatibility issues, we can get more clever, but we need case insensitive regular expressions)
- It adds the ability to do regular expressions (mySQL REGEXP) in the wild card.
To do wild card, you first have to enable wild card searches ($smwgQComparators = ‘<|>|!|~’;)
Then, if the match pattern starts with ‘/’ and ends with either ‘/’ or ‘/i’ (e.g. [[text::~/abc*defg*/i]] then the REGEXP comparison is used in the SQL call. The "i" on the end indicates case insensitive search.
The regex thing thing is only so neat at the moment, as many of the regular expression characters get caught elsewhere in the parser, so we will want to do a bit more work – either we need to identify replacement characters for the standard RE characters of we need to borrow from the DPL2 approach and use special characters for "|", "[", and "{".
There is one issue that I need some help with – the only way that I’ve found to do a case insensitive search is to add “COLLATE utf8_general_ci “ immediately following the LIKE or REGEXP phrase. The problem, however, is that this has to be “ COLLATE latin1_general_ci “ if the database was built as latin character set or UTF8 binary(?) and utf8 otherwise. Lines 373 and 563 have these phrases.
Version: unspecified
Severity: enhancement
Attached: