0% found this document useful (0 votes)
73 views

Install - Elastic Search

This document provides instructions to download, install, and configure Elasticsearch on a system. It includes steps to download the public signing key, install apt-transport-https, configure the Elasticsearch repository, install Elasticsearch, configure Elasticsearch to disable security and set the cluster name and host, start Elasticsearch as a service, index sample Shakespeare data, and perform a search query.

Uploaded by

rajikare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Install - Elastic Search

This document provides instructions to download, install, and configure Elasticsearch on a system. It includes steps to download the public signing key, install apt-transport-https, configure the Elasticsearch repository, install Elasticsearch, configure Elasticsearch to disable security and set the cluster name and host, start Elasticsearch as a service, index sample Shakespeare data, and perform a search query.

Uploaded by

rajikare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Download and install the public signing key:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor


-o /usr/share/keyrings/elasticsearch-keyring.gpg

# Install the apt-transport-https packages

sudo apt-get install apt-transport-https

# Save the repository definition

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg]


https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee
/etc/apt/sources.list.d/elastic-8.x.list

# Install the Elasticsearch Debian package

sudo apt-get update && sudo apt-get install elasticsearch

# Configure Elasticsearch and Disable Security. V8 comes with security enabled

sudo nano /etc/elasticsearch/elasticsearch.yml

node.name: node-1

network.host: 0.0.0.0

discovery.seed.hosts: ["127.0.0.1"]

xpack.security.enabled: false

cluster.initial_master_nodes: ["node-1"]

# Increase default timeout for Elasticsearch start operation. Running Elasticsearch


can be slow on your laptop.

sudo nano /lib/systemd/system/elasticsearch.service

TimeoutStartSec=600

# Open another session and give permissions to read elasticsearch logs

sudo chmod 755 -R /var/log/elasticsearch/

# Configure Elasticsearch to start automatically when the system boots up


sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

# Elasticsearch can be started as follows


sudo /bin/systemctl start elasticsearch.service
sudo /bin/systemctl status elasticsearch.service
# install curl
sudo apt-get install curl

# Check that Elasticsearch is running


curl -XGET 127.0.0.1:9200

# Download mapping for index


sudo wget http://media.sundog-soft.com/es8/shakes-mapping.json

curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/shakespeare --data-


binary @shakes-mapping.json

# Download shakespeare data


sudo wget http://media.sundog-soft.com/es8/shakespeare_8.0.json

# Index data to Elasticsearch


curl -H "Content-Type: application/json" -XPUT '127.0.0.1:9200/shakespeare/_bulk'
--data-binary @shakespeare_8.0.json

# Try searching a phrase

curl -H "Content-Type: application/json" -XGET '127.0.0.1:9200/shakespeare/_search?


pretty' -d '
{
"query" : {
"match_phrase" : {
"text_entry" : "to be or not to be"
}
}
}'

You might also like