using includesAllPrefixes: keywords can result in duplicate results?

Bart Gauquie bart.gauquie at gmail.com
Sat Jan 2 10:46:01 UTC 2010


Dear all,

I've been using the 'keywords' notion of creating indexes on a
MagmaCollection. I create keywords in which some of them have the same
prefix: for instance the keywords can contain: user story 1, user story 2,
user story 3, and so forth.  (which all donate the same object to be found)

If I then do a query on these keywords using:

magmacollection where: [:eachProductBacklog|
       eachProductBacklog keywords includesAllPrefixes: aString substrings]

and try to find 'user' as aString, then the object is returned multiple
times, which is something I do not expect.

If I look at (part of) the implementation of includesAllPrefixes:

expression addTerm: (self copy
     from: eachString
     to: eachString maAlphabeticalNext)

I can understand why multiple results are returned. Magma loops over its
keys from 'user' till 'user' maAlphabeticalNext, and hash key for user story
1 , 2 and 3 match, so that result is returned 3 times.

The easiest way to make them unique is to send the distinct message. Is this
something that always should be done? The docu on the wiki only mentions to
send the distinct keyword if I use an or clause in the query? Of course the
includesAllPrefixes: keywords is a sort of 'or'.
Are there any other ways to make this work (since distinct is slow) ?

Thanks for any advice,

Kind Regards,

Bart

-- 
imagination is more important than knowledge - Albert Einstein
Logic will get you from A to B. Imagination will take you everywhere -
Albert Einstein
Learn from yesterday, live for today, hope for tomorrow. The important thing
is not to stop questioning. - Albert Einstein
The true sign of intelligence is not knowledge but imagination. - Albert
Einstein
However beautiful the strategy, you should occasionally look at the results.
- Sir Winston Churchill
It's not enough that we do our best; sometimes we have to do what's
required. - Sir Winston Churchill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/magma/attachments/20100102/7ab02065/attachment.htm


More information about the Magma mailing list