[Glass] autocomplete functionality with Gemstone 3.6 indexes

Ralph Mauersberger ralph.mauersberger at gmx.net
Fri May 24 10:14:38 PDT 2024

Hello Paul,

not sure about the real point of your question. Gemstone's Programming
Guide has a chapter about creating and using indexes. You can expect
very fast queries with runtimes of just a few milliseconds or even less.
So it should fulfill your performance requirements for type-ahead-froms
in WebApps very well.

You can't send messages like beginsWith: or includesString: in your
index-query's select block; you are limited to string comparison operands.

If all you need is a prefix search, you can go with the following approach:

Assuming you have a class Person with an instance variable name. Put all
your Person Objects in a collection like (Rc)IdentityBag and create an
Equalitiy Index on that instVar. To search your Persons by name prefix,
build a (class side) method like this:

withNamePrefix: namePrefix
     | endString |
     endString := namePrefix, 'ZZZZZ'.
     ^ personCollection select: { :each | (each.name >= namePrefix) &
(each.name < endString) }.

This example uses Gemstone's old query syntax. On 3.6 you could/should
go with the new GsQuery API.

If you need more, e.g. case insensitive substring search, you could
build a helper structure containing all substrings of the names. For
example, build a class PersonNameSuffix with instVars substring and
person. For the person with name "Abcd", build the
PersonNameSuffix-Instances with substring "abcd", "bcd", "cd", "d" and
let all these instances reference that person. Put these instances in a
collection with index on instVar substring. Do that for all persons. You
can then perform your search on that collection and collect all
referenced persons from the result in an IdentitySet.

Hope that helps.


Am 22.05.2024 um 01:17 schrieb Paul DeBruicker via Glass:
> Hi -
> I've got a collection of 1.7 million people and want to search them by
> name (first/last in any order), preferably similarly to the
> autocomplete functionality we're all accustomed to.
> Is there a way to do that with the help of GemStone indexes from 3.6.4?
> Thanks
> Paul
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> https://lists.gemtalksystems.com/mailman/listinfo/glass

More information about the Glass mailing list