Elasticsearch is a distributed search and analytics engine, scalable data store and vector database optimized for speed and relevance on production-scale workloads. Elasticsearch is the foundation of Elastic's open Stack platform. Search in near real-time over massive datasets, perform vector searches, integrate with generative AI applications, and much more.
The script generates a random password for the elastic user, which is displayed at the end of the installation and stored in the .env file.
[CAUTION]
This setup is for local testing only. HTTPS is disabled, and Basic authentication is used for Elasticsearch. For security, Elasticsearch and Kibana are accessible only through localhost.
To connect to your local dev Elasticsearch cluster with a language client, you can use basic authentication with the elastic username and the password stored in the ES_LOCAL_PASSWORD environment variable.
You'll use the following connection details:
Elasticsearch endpoint: http://localhost:9200
Username: elastic
Password: $ES_LOCAL_PASSWORD (Value you set in the environment variable)
For example, to connect with the Python elasticsearch client:
[source,python]
import os
from elasticsearch import Elasticsearch
username = 'elastic'
password = os.getenv('ES_LOCAL_PASSWORD') # Value you set in the environment variable
Kibana's developer console provides an easy way to experiment and test requests.
To access the console, open Kibana, then go to Management > Dev Tools.
Add data
You index data into Elasticsearch by sending JSON objects (documents) through the REST APIs.
Whether you have structured or unstructured text, numerical data, or geospatial data,
Elasticsearch efficiently stores and indexes it in a way that supports fast searches.
For timestamped data such as logs and metrics, you typically add documents to a
data stream made up of multiple auto-generated backing indices.
To add a single document to an index, submit an HTTP post request that targets the index.
POST /customer/_doc/1
{
"firstname": "Jennifer",
"lastname": "Walters"
}
This request automatically creates the customer index if it doesn't exist,
adds a new document that has an ID of 1, and
stores and indexes the firstname and lastname fields.
The new document is available immediately from any node in the cluster.
You can retrieve it with a GET request that specifies its document ID:
GET /customer/_doc/1
To add multiple documents in one request, use the _bulk API.
Bulk data must be newline-delimited JSON (NDJSON).
Each line must end in a newline character (\n), including the last line.
Indexed documents are available for search in near real-time.
The following search matches all customers with a first name of Jennifer
in the customer index.
You can use Discover in Kibana to interactively search and filter your data.
From there, you can start creating visualizations and building and sharing dashboards.
To get started, create a data view that connects to one or more Elasticsearch indices,
data streams, or index aliases.
. Go to Management > Stack Management > Kibana > Data Views.
. Select Create data view.
. Enter a name for the data view and a pattern that matches one or more indices,
such as customer.
. Select Save data view to Kibana.