Elasticsearch

Summary of Elasticsearch used at my work

ElasticSearch 命令文档

5.4 Install Documentation: Install Elasticsearch with Docker | Elasticsearch Reference [5.4] | Elastic

The default password for the elasticuser is changeme

官方中文文档:匹配查询 | Elasticsearch: 权威指南 | Elastic

官方5.4英文文档:Document APIs | Java API [5.4] | Elastic

Web应用查询链接:

Nucbank索引格式

  1. accession, text
  2. definition, text
  3. seqlength, long
  4. organism, text
  5. moleculetype, text
  6. updatedate,date
  7. devision,text
  8. releasedate,date

测试环境单节点启动ElasticSearch

1
nohup docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.4.1 &

创建索引(默认情况下,创建的索引分片数量是 5 个,副本数量是 1 个。)

测试环境:PUT http://192.168.130.19:9200/seqbank/

正式环境:PUT http://192.168.130.21:9200/nucbank/

1
2
3
4
5
6
{
"settings": {
"number_of_shards": 30,
"number_of_replicas": 1
}
}

更新索引字段(以create_date举例)

1
2
3
4
5
6
7
8
{
"properties": {
"create_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}

创建mapping

测试环境:

  1. PUT http://192.168.130.19:9200/seqbank/_mapping/nucleotide

正式环境:

  1. PUT http://192.168.130.21:9200/nucbank/_mapping/nucleotide
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
{
"properties": {
"accession": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"definition": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"seq_length": {
"type": "long"
},
"organism": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"molecule_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"update_date": {
"type": "date",
"format": "yyyy-MM-dd||epoch_millis",
"null_value": "1970-01-01"
},
"devision": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"release_date": {
"type": "date",
"format": "yyyy-MM-dd||epoch_millis",
"null_value": "1970-01-01"
},
"create_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}

使用_bulk批量导入数据

测试环境:POST http://192.168.130.19:9200/seqbank/nucleotide/_bulk

正式环境:POST http://192.168.130.21:9200/nucbank/nucleotide/_bulk

使用:

1
2
{ "index": {}}
{ "accession": "", "definition":"" }

删除索引

测试环境:DELETE http://192.168.130.19:9200/seqbank/

正式环境:DELETE http://192.168.130.21:9200/nucbank/

查看全部索引状态

192.168.130.21:9200/_cat/indices?pretty

查看es集群健康

http://192.168.130.21:9200/_cluster/health

查看es集群状态

192.168.130.21:9200/_cat/health?v

Persist in original technology sharing, your support will encourage me to continue to create!