> For the complete documentation index, see [llms.txt](https://bpmflow.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bpmflow.gitbook.io/project/orbeon-integration/orbeon-persistence-layer-for-gemstone-s/configuration-manual/untitled-4.md).

# Indexing

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.

![](https://3974112602-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LH4gGgyMb1_fhOg782r%2F-LHZBgGoyjnQWZZJa9sh%2F-LHZCKKvPi1HdmiNy92Z%2Findexing.jpg?alt=media\&token=69a64bff-afed-4746-b899-01b5b40472ff)

In order to create indexes a database user has to login to **GemStone/S** using [Jade or Topaz](/project/installation/gemstone-s/login-to-gemstone-s.md) client. To create indexes there are several rules to comply:

**1)** 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**".

**2)** 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**".

Example:\
Once logged into **GemStone/S** execute the following code:\
Create an index on field named *'amount'* in **Form Definition** named *"income\_taxes"* of application *"all\_taxes"* for version 3:

```
| publishedForms |
publishedForms := 
  OrbeonApplication 
    getAllPublishedDefinitionNamed: 'income_taxes' 
    fromApplicationNamed: 'all_taxes' 
    withVersion: 3 
    ifNone: [OrderedCollection new].

publishedForms do: [:each | each createIndexForFieldNamed: 'amount'].

System commit.
```
