diff --git a/docs/api-reference.md b/docs/api-reference.md index 2a3c9686c..9a82c02f6 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -223,9 +223,9 @@ Response: `POST /index//input-definition/` -Creates a input definition in the given index with the given name. +Creates an input definition in the given index with the given name. -The request payload is in JSON, and must contain the `frames` and `fields` field. `frames` is an array of a JSON specifying the frames to use used/created for this import. Each frame must contain a `name` and may contain the following options: +The request payload is JSON, and it must contain the fields `frames` and `fields`. `frames` is an array of frames used within this input definition. Each frame must contain a `name` and may contain the following options: * `rowLabel` (string): Row label of the frame. * `timeQuantum` (string): [Time Quantum]({{< ref "data-model.md#time-quantum" >}}) for this frame. @@ -233,26 +233,53 @@ The request payload is in JSON, and must contain the `frames` and `fields` field * `cacheType` (string): [ranked]({{< ref "data-model.md#ranked" >}}) or [LRU]({{< ref "data-model.md#lru" >}}) caching on this frame. Default is `lru`. * `cacheSize` (int): Number of rows to keep in the cache. Default 50,000. -The `fields` array contains series of json objects describing how to process each field in the JSON data. Each `field` object must contain a string `name` which maps to the source json field name. One field must be defined at the `primaryKey`. The `primarykey` source field must contain only non duplicated unsigned integer values, and the field name must equal the column label for the `Index`. The `primarykey` ID's will map directly to column ID's in Pilosa. +The `fields` array contains a series of JSON objects describing how to process each field received in the input data. Each `field` object must contain a `name` which maps to the source JSON field name. One field must be defined at the `primaryKey`. The `primarykey` source field name must equal the column label for the `Index`, and its value must be an unsigned integer which maps directly to a columnID in Pilosa. -* `name` (string): Maps the source data field to actions that process its value. -* `actions` (array): List of Actions that will process the field's value. +* `name` (string): Maps the source data field to actions that process the field's corresponding value. +* `actions` (array): List of actions that will process the field's value. The `action` describes how the field value will be processed. Each `action` may contain: -* `frame` (string): The Frame that will contain this Action's set bits. +* `frame` (string): The Frame that will contain this action's set bits. * `rowid` (int): The action can use this as a pre-defined SetBit rowID. The user is required to ensure this ID does not overlap with other rows in use per frame. * `valueDestination` (string): The mapping rule used for this data. - - `value-to-row` The value should be an integer and will map directly to a RowID. - - `single-row-boolean` If the value is true set a bit using the `rowid`. - - `mapping` Map the value to a RowID in the `valueMap`. -* `valueMap` (object): string and integer pairs used to map field values to row ID's. + - `value-to-row`: The value should be an integer and will map directly to a RowID. + - `single-row-boolean`: If the value is true set a bit using the `rowid`. + - `mapping`: Map the value to a RowID in the `valueMap`. +* `valueMap` (object): string and integer pairs used to map field values to RowID's. Request: ``` curl localhost:10101/index/user/input-definition/stargazer-input \ -X POST \ - -d '{"frames":[{"name": "language", "options": {"rowLabel": "language_id"}}], "fields":[{"name": "repo_id", "primaryKey":true}, {"name": "language_id", "actions":[{"frame": "language", "valueDestination": "mapping", "valueMap": {"Go":5,"Python":17,"C++":10}}]}]}' + -d '{ + "frames":[ + { + "name": "language", + "options": {"rowLabel": "language_id"} + } + ], + "fields":[ + { + "name": "repo_id", + "primaryKey":true + }, + { + "name": "language_id", + "actions":[ + { + "frame": "language", + "valueDestination": "mapping", + "valueMap": { + "Go": 5, + "Python": 17, + "C++": 10 + } + } + ] + } + ] + }' ``` Response: @@ -264,7 +291,7 @@ Response: `GET /index//input-definition/` -Returns the input definition in JSON. +Returns the given input definition as JSON. Request: ``` @@ -296,9 +323,9 @@ Response: `POST /index//input/` -Process JSON body with the given input definition and set bits. +Processes the JSON payload using the given input definition. -The request payload is a JSON array of objects containing one field for the primary key that corresponds to the column label, and other fields that will be handled by the actions in the input definition. +The request payload is a JSON array of objects containing one field for the primary key that corresponds to the column label, and additional fields that will be handled by corresponding actions in the input definition. Request: ```