This section show how to create index for fast search.
Each Form Definition has a list of fields. In Orbeon a field can be a search field or not. Indexes can only be created in search fields.
If there is an attempt to create an index on a field that is not a search field then the script will answer a proper exception. In this case "IsNotSearchFieldException".
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 expcetion. In this case "CollectionWithout2000ElementsException".
Example: To create an index on field named 'amount' in Form Definition named "income_taxes" of application "all_taxes" with version 3 then execute the following script:
| publishedForms |publishedForms :=OrbeonApplicationgetAllPublishedDefinitionNamed: 'income_taxes'fromApplicationNamed: 'all_taxes'withVersion: 3ifNone: [OrderedCollection new].publishedForms do: [:each | each createIndexForFieldNamed: 'amount'].