Objectivity REST : Indexing Resources : POST /v1/index
POST /v1/index
POST /v1/index
Creates an index for the given class using the given attributes as keys.
Headers 
 
Response Format
Accept:application/json
Body format
Content-Type:application/json
URL Parameters 
fdAlias
Provides the alias of a federated database that is included in the REST server’s configuration file; see Configuring the REST Server in Objectivity/DB Administration.
Body Parameters 
name
Name for the new index.
indexedClass
Name of the class of objects to be indexed. If the class is in a namespace, use namespaceName.className.
isUnique
If set to true, requires that every indexed object have a unique combination of value(s) in its key field(s). After creating a unique index, an attempt to add an object with non-unique key field value(s) results in an exception.
keyAttributes
Provides an array of attributes to use as key fields for sorting indexed objects. If you provide multiple attribute names, the first key is used as the primary sort key.
attributeName specifies the name of the attribute to use as a key field. If the attribute is inherited from a superclass and the name is ambiguous, you can qualify it using superclassName::fieldName.
properties provides a mechanism for configuring the key value.
maxStoredStringLength specifies the maximum length for the key field value. If not specified, the default value is 24.
 
Discussion 
The purpose of an index is to optimize a query operation that searches for persistent objects of the indexed class.
Sample Body 
The following example creates an index for RentalContract objects where the key is the trackingNumber attribute, which must hold a unique value.
{
  "name": "myRentalContractIndex",
  "indexedClass": "FleetData.RentalContract",
  "isUnique": "true",
  "keyedAttributes": 
    [
      {
        "attributeName": "trackingNumber"
      }    
    ]
}
Curl Example 
For more complex bodies such as indexes, provide the contents in a file, for example:
curl -X POST -H "Content-Type:application/json,Accept:application/json" -d @myIndexFile.txt localhost:8185/v1/index
Response 
The response provides the name of the index and its URI.
Status: 201 Created
{
  "name": "myCustomerIndex",
  "uri": "/v1/index/myCustomerIndex"
}
More Samples 
The following example indexes Customer objects on two key fields. The first 34 characters of the firstName primary key are stored in the index. For the rewardPoints attribute, only the first 24 characters are stored (the default value for maxStoredStringLength). Index entries do not need to be unique.
{
  "name": "myCustomerIndex",
  "indexedClass": "FleetData.Customer",
  "isUnique": "false",
  "keyedAttributes": 
    [
      {
        "attributeName": "rewardPoints"
      },
      {
        "attributeName": "firstName",
        "properties": 
          {
            "maxStoredStringLength": "34"
          }
      }
    ]
}
See also 
GET /v1/index to get all indexes
GET /v1/index/{name} to get the named index
DELETE /v1/index/{name} to delete the named index