Help Center/ Cloud Search Service/ Service Overview/ Differences Between Elasticsearch Cluster Versions
Updated on 2024-09-14 GMT+08:00

Differences Between Elasticsearch Cluster Versions

Table 1 Features of different Elasticsearch cluster versions

Version Feature

5. X Version

6. X Version

7. X Version

Supported types

An index can contain multiple types. The name of each type can be customized.

An index can contain only one type, and the type name can be customized.

An index can contain only one type. The type name and _doc are fixed.

Client access

TransportClient is supported. TCP and HTTP can be used for connection requests at the same time.

TransportClient is supported. TCP and HTTP can be used for connection requests at the same time. Java High Level REST Client is recommended.

Only RestClient is supported. Only HTTP can be used for connection requests. Java High Level REST Client is recommended.

The following is an example of using TransportClient to access an Elasticsearch cluster:

//Initialize the client and connect to port 9300.
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300))
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300));
//Close the client.
client.close();

The following is an example of using Java High Level REST Client to access a cluster:

//Initialize the client and connect to port 9200.
RestHighLevelClient client = new RestHighLevelClient(
        RestClient.builder(
                new HttpHost("localhost", 9200, "http"),
                new HttpHost("localhost", 9201, "http")));
//Close the client.
client.close();

Template configuration

The template field is used to create a template.

Example:

PUT _template/template_1
{
  "template": "te*",
  "settings": {
    "number_of_shards": 1
  }
}

The index_pattern field is used to create a template.

Example:

PUT _template/template_1
{
  "index_patterns": ["te*"],
  "settings": {
    "number_of_shards": 1
  }
}

Boolean type parsing

In Elasticsearch 5.x, true, false, on, off, yes, no, 0, and 1 can all be parsed as Boolean values.

Only true and false are supported. If other values are used, an error occurs.

Only in Elasticsearch 6.x or 7.x, errors will be reported for the following statements:

GET data1/_search
{
  "profile": "noprofile",
  "query": {
    "match_all": {}
  }
}

JSON format verification

Duplicate keys are allowed in JSON and will be automatically deleted in the background.

Duplicate keys are not allowed in JSON. Otherwise, a parsing error is reported.

Only in Elasticsearch 6.x or 7.x, errors will be reported for the following statements:

POST data1/doc
{
  "isl": 0,
  "isl": 1
}

DELETE document

If index1 does not exist and you run the DELETE index1/doc/1 command, the system will create index1.

If you run a command to delete an index that does not exist, an error message is displayed.

_alias API validation

The index field in the _alias API can be specified as an alias and can be parsed properly.

You can also use an alias to delete an index.

The index field in the _alias API can only be specified as an index name and cannot be an alias.

To delete an index, the index name is required.

The following command can run properly in Elasticsearch 5.x, but an error is reported when you run it in Elasticsearch 6.x or 7.x.

PUT log-2023.11.11
POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "log-2023.11.11",
        "alias": "log"
      }
    }
  ]
}
POST _aliases
{
  "actions": [
    {
      "remove": {
        "index": "log",
        "alias": "log"
      }
    }
  ]
}

Error message:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "The provided expression [log] matches an alias, specify the corresponding concrete indices instead."
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "The provided expression [log] matches an alias, specify the corresponding concrete indices instead."
  },
  "status" : 400
}

Default configurations

The default number of shards for a new index: 5

The default number of shards for a new index: 1

Default routing

In Elasticsearch 5.x/6.x, the following formula is used to calculate the shard where the document should be located:

shard_num = hash(_routing) % num_of_primary_shards

In Elasticsearch 7.x, the following formula is used to calculate the shard where the document should be located:

routing_factor = num_routing_shards / num_primary_shards 
shard_num = (hash(_routing) % num_routing_shards) / routing_factor

The following command can be used to specify the value of num_routing_shards:

index.number_of_routing_shards

If this parameter is not explicitly specified, Elasticsearch automatically calculates the value to split indexes.

Refresh time

By default, the refresh operation is performed every second.

If index.refresh_interval is not explicitly specified and indexes do not receive the search request for long time (the duration is specified by index.search.idle.after and the value is 30 seconds by default), Elasticsearch does not periodically refresh until when a new search request is received. In this case, search requests are not returned until the next refresh is complete. Therefore, the first search request takes a long time.

Parent fuse

The parent fuse is triggered when the sum of memory statistics in multiple child fuses exceeds the threshold. The default threshold is 70%.

The parent fuse is triggered when the heap memory usage exceeds the threshold. The default threshold is 95%.

Field Data fuse threshold

The default value of indices.breaker.fielddata.limit is 60%.

The default value of indices.breaker.fielddata.limit is 40%.

The _all field

Supported

Discarded

Deleted

hits.total returned by the search API

hits.total returned by the search API is a number, indicating the number of hits.

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 4,
    "max_score": 1,
  }
}

hits.total is not a number.

{
  "took" : 76,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.0
  }
}

In the preceding information:

value indicates the number of matched records.

relation indicates whether the number of hit records in the value parameter is accurate.

eq indicates an accurate value.

gte indicates that the number of hit records is greater than or equal to the value parameter.

_cache/clear API

The POST and GET methods are supported.

Only the POST method is supported.