This repository provides a comprehensive guide to setting up, configuring, and using Elasticsearch effectively with Python 3. It includes best practices, hands-on examples, and real-world use cases to help you leverage Elasticsearch for search, analytics, and data management.
- Powerful Search Capabilities: Supports full-text search, fuzzy matching, and relevance scoring.
- Scalable & Distributed: Handles large datasets efficiently with horizontal scaling.
- Real-time Data Processing: Enables quick indexing and retrieval of structured and unstructured data.
- Custom Mappings & Analyzers: Define schemas and optimize search performance.
- Integration with Kibana & Logstash: Provides visualization and data processing capabilities.
- Python 3.x
- Elasticsearch and
elasticsearch-py
Python client - Docker (recommended) or direct installation
- Java 11+ (if running without Docker)
- Basic understanding of JSON and RESTful APIs
docker network create elastic
docker run --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
docker.elastic.co/elasticsearch/elasticsearch:8.6.2
Use the docker compose file and run the following command
docker-compose -f path/to/docker-compose.yaml up
Use run.sh file see run.sh file: Link [click me]
# change the chmod of the run.sh file
chmode +x run.sh
# execute the run.sh file
./run.sh
- Download Elasticsearch.
- Extract and navigate to the directory.
- Run Elasticsearch:
./bin/elasticsearch
- Access the UI via
http://localhost:9200
.
pip install elasticsearch
from elasticsearch import Elasticsearch
es = Elasticsearch(["http://localhost:9200"])
print(es.info())
es.indices.create(index="my_index", body={
"settings": {"number_of_shards": 1, "number_of_replicas": 1}
})
doc = {"title": "Introduction to Elasticsearch", "content": "Elasticsearch is a powerful search and analytics engine."}
es.index(index="my_index", id=1, document=doc)
resp = es.search(index="my_index", query={"match": {"title": "Elasticsearch"}})
print(resp)
/elastic-search
├── configs/ # Elasticsearch configurations
├── scripts/ # Custom automation scripts
├── data/ # Sample datasets
├── logs/ # Elasticsearch logs
├── docs/ # Documentation and guides
└── README.md # This file
- Use proper indexing strategies to improve search efficiency.
- Optimize queries and filters to reduce execution time.
- Implement snapshot and backup mechanisms to prevent data loss.
- Enable monitoring and logging to analyze performance and troubleshoot issues.
👤 Vivek Kumar Verma
📧 Contact: vivekkumarverma332@gmail.com
🔗 GitHub: https://github.com/dev-vivekkumarverma
For notes and Use : Link [click me...]