json
index.create
Create a JSON secondary index on a field path.
strata json index createdb.json.create_index(name: 'str', field_path: 'str', *, index_type: 'str' = 'tag') -> 'Any'wire json_create_index
Creates a secondary index over one JSON field path with a numeric, tag, or text kind. Existing documents are indexed at creation and future writes maintain the index automatically. The current wire response is a transitional bare index definition.
Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.
To see the complete help for this command, run:
strata json index create --helphelp(db.json.create_index)
Example
Create a secondary index on a JSON field.
strata json index create by_name $.name --index-type tagstrata json index list
_ = db.json.create_index("by_name", "$.name", index_type="tag")[i.name for i in db.json.list_indexes()]
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| field_path | string | yes | Indexed field path. |
| index_type | JsonIndexType | yes | Index kind.one of: numeric, tag, text |
| name | string | yes | Index name. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck<JsonIndexCreate>
- dataJsonIndexDefinition
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.json_index_name | never | not_started |
| invalid_argument.engine.json_index_name_reserved | never | not_started |
| invalid_argument.engine.json_path | never | not_started |
| invalid_argument.engine.json_path_too_long | never | not_started |
| already_exists.engine.json_index | never | not_started |