root@Elasticsearch-10:~#
root@Elasticsearch-10:~# apt-get update -y
root@Elasticsearch-10:~# apt-get full-upgrade -y
root@Elasticsearch-10:~# apt-get install gnupg gnupg2 gnupg2 -y
root@Elasticsearch-10:~# wget -qO – https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add –
OK
root@Elasticsearch-10:~# apt-get install apt-transport-https
root@pve-02-ubuntu-2:~# echo „deb https://artifacts.elastic.co/packages/7.x/apt stable main“ | tee -a /etc/apt/sources.list.d/elastic-7.x.list
deb https://artifacts.elastic.co/packages/7.x/apt stable main
root@pve-02-ubuntu-2:~# apt-get update -y
root@pve-02-ubuntu-2:~# apt-get install elasticsearch
root@pve-02-ubuntu-2:~# systemctl daemon-reload
root@pve-02-ubuntu-2:~# systemctl enable elasticsearch.service
root@pve-02-ubuntu-2:~# systemctl start elasticsearch.service
root@Elasticsearch-10:~# apt-get install curl
root@Elasticsearch-10:~# curl http://localhost:9200
{
„name“ : „Elasticsearch-10“,
„cluster_name“ : „elasticsearch“,
„cluster_uuid“ : „7XCqjwV7SdWbMOCmVW8xVw“,
„version“ : {
„number“ : „7.14.0“,
„build_flavor“ : „default“,
„build_type“ : „deb“,
„build_hash“ : „dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1“,
„build_date“ : „2021-07-29T20:49:32.864135063Z“,
„build_snapshot“ : false,
„lucene_version“ : „8.9.0“,
„minimum_wire_compatibility_version“ : „6.8.0“,
„minimum_index_compatibility_version“ : „6.0.0-beta1“
},
„tagline“ : „You Know, for Search“
}
root@Elasticsearch-10:~#
root@Elasticsearch-10:~# systemctl status elasticsearch.service
* elasticsearch.service – Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-08-18 12:26:01 UTC; 3min 56s ago
Docs: https://www.elastic.co
Main PID: 149 (java)
Tasks: 64 (limit: 17848)
Memory: 8.0G
CPU: 1min 17.404s
CGroup: /system.slice/elasticsearch.service
|-149 /usr/share/elasticsearch/jdk/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch >
`-498 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
Aug 18 12:25:37 Elasticsearch-10 systemd[1]: Starting Elasticsearch…
Aug 18 12:26:01 Elasticsearch-10 systemd[1]: Started Elasticsearch.
root@Elasticsearch-10:~# curl -X GET „localhost:9200/_cat/indices?v&pretty“
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases hBK8M62nQSagipE5KxDD0Q 1 0 42 0 40.1mb 40.1mb
root@Elasticsearch-10:~# curl -XPUT ‚localhost:9200/products/mobiles/1?pretty‘ -H ‚Content-Type: application/json‘ -d‘
{
„name“: „iPhone 7“,
„camera“: „12MP“,
„storage“: „256GB“,
„display“: „4.7inch“,
„battery“: „1,960mAh“,
„reviews“: [„Incredibly happy after having used it for one week“, „Best iPhone so far“, „Very expensive, stick to Android“]
}
‚
{
„_index“ : „products“,
„_type“ : „mobiles“,
„_id“ : „1“,
„_version“ : 1,
„result“ : „created“,
„_shards“ : {
„total“ : 2,
„successful“ : 1,
„failed“ : 0
},
„_seq_no“ : 0,
„_primary_term“ : 1
}
root@Elasticsearch-10:~# curl -X GET „localhost:9200/_cat/indices?v&pretty“
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases hBK8M62nQSagipE5KxDD0Q 1 0 42 0 40.1mb 40.1mb
yellow open products 8AkZHUrdQ1yTv12KjQ5oJA 1 1 1 0 7.2kb 7.2kb
root@Elasticsearch-10:~#
root@Elasticsearch-10:~# curl -XGET „localhost:9200/products/_search?pretty“ -H ‚Content-Type: application/json‘
{
„took“ : 4,
„timed_out“ : false,
„_shards“ : {
„total“ : 1,
„successful“ : 1,
„skipped“ : 0,
„failed“ : 0
},
„hits“ : {
„total“ : {
„value“ : 1,
„relation“ : „eq“
},
„max_score“ : 1.0,
„hits“ : [
{
„_index“ : „products“,
„_type“ : „mobiles“,
„_id“ : „1“,
„_score“ : 1.0,
„_source“ : {
„name“ : „iPhone 7“,
„camera“ : „12MP“,
„storage“ : „256GB“,
„display“ : „4.7inch“,
„battery“ : „1,960mAh“,
„reviews“ : [
„Incredibly happy after having used it for one week“,
„Best iPhone so far“,
„Very expensive, stick to Android“
]
}
}
]
}
}
root@Elasticsearch-10:~# curl -XGET „localhost:9200/products/_search?pretty“ -H ‚Content-Type: application/json‘ -d‘
{
„query“: {
„match_phrase“: {
„camera“: „12MP“
}
}
}‘
{
„took“ : 7,
„timed_out“ : false,
„_shards“ : {
„total“ : 1,
„successful“ : 1,
„skipped“ : 0,
„failed“ : 0
},
„hits“ : {
„total“ : {
„value“ : 1,
„relation“ : „eq“
},
„max_score“ : 0.2876821,
„hits“ : [
{
„_index“ : „products“,
„_type“ : „mobiles“,
„_id“ : „1“,
„_score“ : 0.2876821,
„_source“ : {
„name“ : „iPhone 7“,
„camera“ : „12MP“,
„storage“ : „256GB“,
„display“ : „4.7inch“,
„battery“ : „1,960mAh“,
„reviews“ : [
„Incredibly happy after having used it for one week“,
„Best iPhone so far“,
„Very expensive, stick to Android“
]
}
}
]
}
}
### Loading sample data – the complete works of William Shakespeare suitably parsed into fields shakespeare.json
root@Elasticsearch-10:~# curl -X GET „localhost:9200/_cat/indices?v&pretty“
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases hBK8M62nQSagipE5KxDD0Q 1 0 42 38 40.1mb 40.1mb
yellow open products 8AkZHUrdQ1yTv12KjQ5oJA 1 1 1 0 7.3kb 7.3kb
root@Elasticsearch-10:~# curl -XPUT „localhost:9200/shakespeare/_bulk?pretty“ -H ‚Content-Type: application/json‘ –data-binary @shakespeare_6.0.json
root@Elasticsearch-10:~# curl -X GET „localhost:9200/_cat/indices?v&pretty“
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases hBK8M62nQSagipE5KxDD0Q 1 0 42 38 40.1mb 40.1mb
yellow open shakespeare -YUARRYPSYO170-U1-N6gg 1 1 111396 0 19mb 19mb
yellow open products 8AkZHUrdQ1yTv12KjQ5oJA 1 1 1 0 7.3kb 7.3kb
root@Elasticsearch-10:~# curl -XGET „localhost:9200/shakespeare/_search?pretty“ -H ‚Content-Type: application/json‘ -d‘
{
„query“: {
„match_phrase“: {
„text_entry“: „So shaken as we are“
}
}
}
‚
{
„took“ : 27,
„timed_out“ : false,
„_shards“ : {
„total“ : 1,
„successful“ : 1,
„skipped“ : 0,
„failed“ : 0
},
„hits“ : {
„total“ : {
„value“ : 1,
„relation“ : „eq“
},
„max_score“ : 21.60624,
„hits“ : [
{
„_index“ : „shakespeare“,
„_type“ : „_doc“,
„_id“ : „3“,
„_score“ : 21.60624,
„_source“ : {
„type“ : „line“,
„line_id“ : 4,
„play_name“ : „Henry IV“,
„speech_number“ : 1,
„line_number“ : „1.1.1“,
„speaker“ : „KING HENRY IV“,
„text_entry“ : „So shaken as we are, so wan with care,“
}
}
]
}
}
root@Elasticsearch-10:~#
### Elasticsearch Loader – for batch loading data files (json, parquet, csv, tsv) into Elasticsearch
root@Elasticsearch-10:~# apt-get update -y
root@Elasticsearch-10:~# apt-get install pip
root@Elasticsearch-10:~# pip install elasticsearch-loader
### JSON files with the format of [{„a“: „1“}, {„b“: „2“}]
root@Elasticsearch-10:~# elasticsearch_loader –index licenses –type license json licenses.json
root@Elasticsearch-10:~# curl -X GET „localhost:9200/_cat/indices?v&pretty“
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases hBK8M62nQSagipE5KxDD0Q 1 0 42 42 40.1mb 40.1mb
yellow open licenses EQm3fIu7Qn2JLlqWP01HyA 1 1 9120 0 1.4mb 1.4mb
yellow open shakespeare -YUARRYPSYO170-U1-N6gg 1 1 111396 0 19mb 19mb
yellow open products 8AkZHUrdQ1yTv12KjQ5oJA 1 1 1 0 7.3kb 7.3kb
root@Elasticsearch-10:~# curl -X GET „localhost:9200/licenses/_search?pretty“ -H ‚Content-Type: application/json‘
root@Elasticsearch-10:~# curl -X GET „localhost:9200/licenses/_search?q=CITY:Hamburg“
### Install Kibana with Debian package