All Products
Search
Document Center

OpenSearch:cluster clause

Last Updated:Feb 28, 2024

Overview

A cluster clause is optional. You can use the cluster clause to specify the partitions in a cluster in which you want to perform a query.

Syntax

Specify partition field values

{
  "cluster" : {  
    "hash_field" : []
  }
}

The hash_field parameter specifies the original values of the partition field. You can specify multiple values for this parameter. OpenSearch Retrieval Engine Edition hashes the values that you specify, calculates the IDs of the corresponding partitions, and then queries data in the partitions. Examples:

# Query data in the partitions that correspond to the hash values of 123 and 456.
{
  "cluster" : {  
    "hash_field" : ["123", "456"]
  }
}

# Query data in the partition that corresponds to the hash value of abc.
{
  "cluster" : {  
    "hash_field" : ["abc"]
  }
}

Specify document hash IDs

{
  "cluster" : {  
    "part_ids" : []
  }
}

If the hash ID of a document in a partition is returned from the results of a query, you can specify the hash ID of the document to query data in the partition. The hash ID of a document in a partition must be in the range of 0 to 65535. For example, if a cluster has two partitions, the hash IDs of documents in one partition must be in the range of 0 to 32767 and the hash IDs of documents in the other partition must be in the range of 32768 to 65535. If the hash ID of a document that you specify falls within the hash ID range of a partition, data in the partition is queried. Example:

# Query data in the partitions that correspond to the hash IDs 123 and 8790.
{
  "cluster" : {
    "part_ids" : [123,8790]
  }
}

Usage notes

  • You can specify only one of the hash_field and part_ids parameters in a cluster clause.