In order to create indexes a database user has to login to GemStone/S using Jade or Topaz client. To create indexes there are several rules to comply:
1) Indexes are an optimization and it worth it if there are more than 2000 elements in the fields collection. For that particular Form Definition must be at least 2000 Form Instances in order to create an index on any search field. An attempt by a script to create an index in a collection with less than 2000 elements will raise a proper exception. In this case "CollectionWithout2000ElementsException".
"For process definition 'visa-appliance' version 1 in Environment 'env-ue' in application 'ue' it would create a string index on form 'citizen-appliance' field 'originCountry[s]'. Where [s] is the type of the field."
| environment application processDefinition |
environment := BpmEnvironment getEnvironmentNamed: 'env-ue' ifNone: [^nil].
application := environment applicationNamed: 'ue' ifNone: [^nil].
processDefinition := application getProcessesNamed: 'visa-appliance' version: 1 ifNone: [^nil].
processDefinition createFieldIndexInForm: 'citizen-appliance' forFieldNamed: 'originCountry[s]' type: String.