All Products
Search
Document Center

OpenSearch:Compound data types

Last Updated:Jan 19, 2026

The Industry Algorithm Edition supports two compound data types: OBJECT and NESTED. These types allow you to combine multiple fields into a nested structure. Using compound data types correctly improves query accuracy, prevents mismatches, and makes complex data management more efficient.

Usage notes

OBJECT and NESTED types accept JSON data with the same structure and have similar basic configurations. However, their query behavior is fundamentally different. The NESTED type preserves object boundaries, while the OBJECT type flattens the data.

Type

OBJECT

NESTED

Underlying storage method

Flattened storage, which loses object boundaries.
For example:
{ "user": [{"name":"Alice","age":30}, {"name":"Bob","age":25}] }
Is stored as:
user_name: ["Alice", "Bob"]
user_age: [30, 25]













Uses independent storage for parent and child documents, preserving object integrity.

Query semantics

Cross-object matches can occur, but performance is better.
Example: user_name: "Alice" AND user_age: 25

This can match different user objects: Alice (age 30) and Bob (age 25).

Matching is strictly limited to a single object.
Example: user_name: "Alice" AND user_age: 30

Can only match the single user object where name="Alice" and age=30.

Limitations

The inner fields of OBJECT and NESTED types are flattened by level, and the levels are joined by underscores. These fields can be configured in the index schema and as property fields.

  • The Industry Algorithm Edition has the following limits for OBJECT and NESTED fields:

    • The total number of fields cannot exceed 10.

    • The maximum nesting depth is 5 levels.

    • The field itself cannot be a property.

    • Other fields at the same level cannot have names that start with the prefix {OBJECT_field_name}_ or {NESTED_field_name}_. For example, if an OBJECT field is named abc, another field at the same level cannot be named abc_d.

    • Only Dedicated applications are supported.

  • The inner fields of OBJECT and NESTED types have the following limits:

    • Vector analyzers are not supported.

    • Cannot be configured as a routing field, an inverted index sort field, or a vector index namespace.

    • Compound indexes are not supported.

    • The created index name must be the same as the field name.

    • Sort expressions are not supported.

    • Cannot be configured as a display field.

    • Cannot be configured as a model training field.

Examples

Application creation

For more information about the syntax, see Schema.

{
  "name": "json_nested",
  "type": "NESTED",
  "primaryKey": false,
  "innerSchema": {
    "job": {
      "name": "job",
      "type": "TEXT",
      "primaryKey": false
    },
    "ssn": {
      "name": "ssn",
      "type": "LITERAL",
      "primaryKey": false
    }
  }
}

Field

Type

Description

type

String

The data type of the field. For more information about field details, see Application schema.

name

String

The field name.

primaryKey

Boolean

Indicates whether the field is a primary key.

joinWith

Array

The collection of data tables to join with.

innerSchema

Object

Specifies the data structure when the field type is OBJECT or NESTED. Nesting is supported.

Data push

For an OBJECT type, the value of the field is a JSON string.

[
    {
        "cmd": "add",
        "timestamp": 1401342874777,
        "fields": {
            "id": "1",
            "title": "This is the title",
            "json_nested": "[{\"job\":\"Other\",\"ssn\":\"abc\"}]"
        }
    },
    {
        "cmd": "update",
        "timestamp": 1401342874778,
        "fields": {
            "id": "1",
            "json_nested": "{\"job\":\"Security Officer\",\"ssn\":\"abc\"}" // Can be a single object
        }
    },
    {
        "cmd": "delete",
        "fields": {
            "id": "1"
        }
    }
]

Search

  • Using indexes for the inner fields of OBJECT and NESTED types is the same as for regular fields.

  • To filter by an inner field of a NESTED type, add sub_doc:group or sub_doc:flat to the config clause.

  • To sort by an inner field of a NESTED type, add sub_doc:flat to the config clause.

Example:

query=json_nested_job:'Other'&&filter=json_nested_ssn="abc"&&sort=json_nested_ssn;-RANK&&config=sub_doc:flat
Note

The sub_doc:flat mode has slightly lower performance than the sub_doc:group mode.