Elasticsearch6.3的新特性

2018-06-15 11:02:17

Elasticsearch 官方推出了6.3.0,今天,让我们看一下 Elasticsearch6.3.0给我们带来的新特性吧,如果想看官网的同学可以参考这里

  • Elasticsearch6.3默认包含了X-Pack,X-Pack包括APM,Canvas
  • 支持SQL
  • 支持Java 10
  • 汇总统计
  • 安全更新
支持SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#创建index并添加数据
[root@localhost ~]# curl -X PUT "localhost:9200/library/book/_bulk?refresh" -H 'Content-Type: application/json' -d'
> {"index":{"_id": "Leviathan Wakes"}}
> {"name": "Leviathan Wakes", "author": "James S.A. Corey", "release_date": "2011-06-02", "page_count": 561}
> {"index":{"_id": "Hyperion"}}
> {"name": "Hyperion", "author": "Dan Simmons", "release_date": "1989-05-26", "page_count": 482}
> {"index":{"_id": "Dune"}}
> {"name": "Dune", "author": "Frank Herbert", "release_date": "1965-06-01", "page_count": 604}
> '
{"took":426,"errors":false,"items":[{"index":{"_index":"library","_type":"book","_id":"Leviathan Wakes","_version":1,"result":"created","forced_refresh":true,"_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1,"status":201}},{"index":{"_index":"library","_type":"book","_id":"Hyperion","_version":1,"result":"created","forced_refresh":true,"_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1,"status":201}},{"index":{"_index":"library","_type":"book","_id":"Dune","_version":1,"result":"created","forced_refresh":true,"_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1,"status":201}}]}

#通过SQL REST API执行SQL
[root@localhost ~]# curl -X POST "localhost:9200/_xpack/sql?format=txt" -H 'Content-Type: application/json' -d'
> {
> "query": "SELECT * FROM library WHERE release_date < \u00272000-01-01\u0027"
> }
> '
author | name | page_count | release_date
---------------+---------------+---------------+------------------------
Dan Simmons |Hyperion |482 |1989-05-26T00:00:00.000Z
Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z


#支持SQL REST API
[root@localhost ~]# curl -X POST "localhost:9200/_xpack/sql/translate" -H 'Content-Type: application/json' -d'
> {
> "query": "SELECT * FROM library ORDER BY page_count DESC",
> "fetch_size": 10
> }
> '
{"size":10,"_source":{"includes":["author","name"],"excludes":[]},"docvalue_fields":["page_count","release_date"],"sort":[{"page_count":{"order":"desc"}}]}

#支持SQL CLI
[root@localhost ~]# /usr/share/elasticsearch/bin/elasticsearch-sql-cli
.sssssss.` .sssssss.
.:sXXXXXXXXXXo` `ohXXXXXXXXXho.
.yXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXXX-
.XXXXXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXXXXXX.
.XXXXXXXXXXXXXXXXXXXXo. .oXXXXXXXXXXXXXXXXXXXXh
.XXXXXXXXXXXXXXXXXXXXXXo``oXXXXXXXXXXXXXXXXXXXXXXy
`yXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
`oXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXXXXXo`
.XXXXXXXXXXXXXXXXXXXXXXXXXo`
.oXXXXXXXXXXXXXXXXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXo` `odo`
`oXXXXXXXXXXXXXXXXXXXXXXXXo` `oXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXo` `oXXXXXXXXXo`
`oXXXXXXXXXXXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXo`
`yXXXXXXXXXXXXXXXXXXXXXXXo` oXXXXXXXXXXXXXXXXX.
.XXXXXXXXXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXXXXXXXy
.XXXXXXXXXXXXXXXXXXXXo` /XXXXXXXXXXXXXXXXXXXXX
.XXXXXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXXXXXX-
-XXXXXXXXXXXXXXXo` `oXXXXXXXXXXXXXXXo`
.oXXXXXXXXXXXo` `oXXXXXXXXXXXo.
`.sshXXyso` SQL `.sshXhss.`

sql> SELECT * FROM library WHERE release_date < '2000-01-01';
author | name | page_count | release_date
---------------+---------------+---------------+------------------------
Dan Simmons |Hyperion |482 |1989-05-26T00:00:00.000Z
Frank Herbert |Dune |604 |1965-06-01T00:00:00.000Z

#支持SQL JDBC

String address = "jdbc:es://" + elasticsearchAddress;
Properties connectionProperties = connectionProperties();
Connection connection = DriverManager.getConnection(address, connectionProperties);
try (Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery(
"SELECT name, page_count FROM library ORDER BY page_count DESC LIMIT 1")) {
assertTrue(results.next());
assertEquals("Don Quixote", results.getString(1));
assertEquals(1072, results.getInt(2));
SQLException e = expectThrows(SQLException.class, () -> results.getInt(1));
assertTrue(e.getMessage(), e.getMessage().contains("unable to convert column 1 to an int"));
assertFalse(results.next());
}
支持Java 10

Elasticsearch 支持Java9 和Java10,保持和Java快速发布周期一致。但是官方建议大多数用户使用java8,有兴趣的同学可以看这里

汇总统计

用户可以建立汇总统计job,job会汇聚统计最近搜索的更新数据。这个功能和SQl功能一样,都是实验性质的功能。

安全更新

XPackExtension 扩展机制被移除了,引入SPI扩展机制。

Bug fixes

具体可以参考这里

说了这么多,也许有朋友问了,怎么才能升级到Elasticsearch6.3呢,官方建议是:、

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1. 6.x到6.y - 可以通过一次升级一个节点来执行
2. 5.x至6.x - 需要完全重启群集
3. 2.x至6.x - 不支持

[root@localhost ~]# curl -XGET 'http://localhost:9200/'
{
"name" : "99NPxaU",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "gW7bp0I3RNKvZI50SAsjeg",
"version" : {
"number" : "6.3.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "424e937",
"build_date" : "2018-06-11T23:38:03.357887Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}


您的鼓励是我写作最大的动力

俗话说,投资效率是最好的投资。 如果您感觉我的文章质量不错,读后收获很大,预计能为您提高 10% 的工作效率,不妨小额捐助我一下,让我有动力继续写出更多好文章。