Range Queries fail for MaSearchStringIndex when using Umlauts
Udo Schneider
udo.schneider at homeaddress.de
Wed Oct 13 19:22:21 UTC 2010
All,
I'm currently using Magma to perform a prefix search on City names. I
found out that this fails if the string contains umlauts or, to be more
precise, if the last given char is not Ascii.
E.g.
myCollection where: [ :reader | reader read: #city from: 'Me' to: 'Me'
maAlphabeticalNext]
works fine. Changing the prefix to 'Mü' fails (no result).
I assume that this is somehow connected to a) maAlphabeticalNext and b)
the "allowed" characters for MaSearchStringIndex (BTW: #beAscii doesn't
help here). I'm currently using MaByteSequenceIndex to circumvent the
problem but I am not sure whether this is the intention.
I attached a Testcase which shows the problem.
Thanks,
Udo
-------------- next part --------------
'From Pharo-1.1-11411 of 17 July 2010 [Latest update: #11411] on 13 October 2010 at 9:15:35 pm'!
TestCase subclass: #BWRangeQueryTests
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Bankwertung-Tests'!
!BWRangeQueryTests methodsFor: 'as yet unclassified' stamp: 'UdoSchneider 10/13/2010 21:13'!
cities
^ #('Meppen' 'Münster' 'München' 'Wien')! !
!BWRangeQueryTests methodsFor: 'as yet unclassified' stamp: 'UdoSchneider 10/13/2010 21:14'!
testByteSequenceIndexUmlautRangeQuery
| collection index result |
collection := MagmaCollection new.
collection
addIndex:
((MaByteSequenceIndex attribute: #yourself)
keySize: 128;
yourself);
addAll: self cities.
result := collection where: [ :reader | reader read: #yourself from: 'Meppen' to: 'Wien' ].
self assert: result size = 4.
result := collection where: [ :reader | reader read: #yourself from: 'Mü' to: 'Mü' maAlphabeticalNext ].
self assert: result size = 2! !
!BWRangeQueryTests methodsFor: 'as yet unclassified' stamp: 'UdoSchneider 10/13/2010 21:15'!
testSearchStringIndexUmlautRangeQuery
| collection index result |
collection := MagmaCollection new.
collection
addIndex:
((MaSearchStringIndex attribute: #yourself)
keySize: 128;
yourself);
addAll: self cities.
result := collection where: [ :reader | reader read: #yourself from: 'Meppen' to: 'Wien' ].
self assert: result size = 4.
result := collection where: [ :reader | reader read: #yourself from: 'Mü' to: 'Mü' maAlphabeticalNext ].
self assert: result size = 2! !
More information about the Magma
mailing list