Hi Chris,
Hi Brent!
I think you've cleverly solved your own question.. By indexing the reversed value, its no different than a keyword index where you can already query on the presence of multiple keywords, as in:
myArticles where: [ : each | (each keywords equals: 'Squeak') & (each keywords equals: 'Magma') ]
So you would just have to convert the wildcards to multiple conjunctions, for example, 'foo%bar' would just have to be translated to:
self people where: [ : each | (each familyName startsWith: 'foo') & (each familyName endsWith: 'bar') ]
and the index would have something like:
startsWith: aString self equals: aString endsWith: aString self equals: aString reversed
You don't even need a separate "reversed" index, just add two entries (the forward and reversed) for each object added to the collection.
Domo arigato gozaimasu Sensei
Now, the expression '%foo%bar%' goes beyond the first requirement of just searching on a prefix and/or a suffix.. For this a different type of index would be needed that adds every possible value for "Fredfoon Tobart", the following values:
fredfoon tobart redfoon tobart edfoon tobart dfoon tobart foon tobart oon tobart on tobart n tobart tobart tobart obart bart art rt t
Your '%foo%bar%' expression would then need to translate to
(familyName from: 'foo' to: 'foo' maAlphabeticalNext) & (familyName from: 'bar' to: 'bar' maAlphabeticalNext)
to find the object(s) that had "Fredfoon Tobart".
I must admit I am not following you here. Is this one of those Magma keyword indices which I have never managed to grok ?
Also, whilst you are hunting elephants, SQL has both % and ? wildcards: % is any sequence of characters inlcuding the empty string and ? is precicely one character. So foo??bar would match fooABbar but not fooCDEbar and not fooFbar.
Any chance you could bend Magma's indices into managing expressions with a fixed number of ?s (e.g. ?foo????bar??baz???)
It is to darn hot here to think.
Brent