Use automatic indexing rules for z/TPF support for MongoDB
With standard MongoDB servers, you can add indexes for fields in the document that allows optimized retrieval when the document is located by using that field. The indexes for these fields are maintained by the standard MongoDB server. Maintenance of these indexes is transparent to the end user who accesses the standard MongoDB server.
In z/TPFDF, no database definitions associate the fields of a subfile to the indexes for that subfile. Therefore, you must programmatically add or remove indexes for documents when you use z/TPFDF.
To avoid programmatically maintaining indexes, you can use z/TPF support for MongoDB to define automatic indexing rules for index names. You can define automatic indexing rules for index names in the z/TPFDF collection descriptor. The automatic indexing rules map fields in a document to the parameters that are required for indexing. For example, consider the sample PNR that is described in an example of a z/TPFDF file. The PnrByNumber index is used to access the PNR, and a PassengerNumberRecord consists of a unique 8-byte value for the PNR. For every PassengerNumberRecord in the PNR, an index is created by the application in the PnrByNumber index.
By defining an automatic indexing rule for this index, z/TPF support for MongoDB manages the PnrByNumber index when PassengerNumberRecords are inserted, removed, or updated. In this case, you can avoid programmatically maintaining indexes in MongoDB remote applications.
- The data that is required for an index must exist as fields in a record of the document.
- All of the data that is required for an index must be contained in one record type.
- If an index operation is issued and the index already exists for that document, the operation is considered successful.
- If a deindex operation is issued and index does not exist for that document, the operation is successful.