Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

refactor: organize Elasticsearch examples and verify integration

LearningCircuitf335deed0151
diff --git a/examples/elasticsearch/README.md b/examples/elasticsearch/README.md
new file mode 100644
index 0000000000..0d74a9074f
--- /dev/null
+++ b/examples/elasticsearch/README.md
@@ -0,0 +1,40 @@
+# Elasticsearch Integration Example
+
+Quick setup guide to test Elasticsearch with Local Deep Research.
+
+## Quick Start
+
+1. **Start Elasticsearch**
+ ```bash
+ # From the examples/elasticsearch directory:
+ sudo docker compose up -d
+
+ # Or to see logs while it starts:
+ sudo docker compose up
+ ```
+
+2. **Index sample documents**
+ ```bash
+ python search_example.py
+ ```
+
+3. **Configure in Web UI**
+ - Go to Settings → Search Engines → Elasticsearch
+ - Default settings should work (http://localhost:9200)
+ - Index name: `documents`
+
+4. **Stop Elasticsearch**
+ ```bash
+ sudo docker compose down
+ ```
+
+## Files
+
+- `docker-compose.yml` - Elasticsearch container setup
+- `search_example.py` - Example script to index and search documents
+- `test_elasticsearch.sh` - Shell script to verify Elasticsearch is running
+
+## Requirements
+
+- Docker and Docker Compose
+- Python with project dependencies installed
diff --git a/examples/elasticsearch/docker-compose.yml b/examples/elasticsearch/docker-compose.yml
new file mode 100644
index 0000000000..0653ac1399
--- /dev/null
+++ b/examples/elasticsearch/docker-compose.yml
@@ -0,0 +1,16 @@
+services:
+ elasticsearch:
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
+ container_name: elasticsearch-local
+ environment:
+ - discovery.type=single-node
+ - xpack.security.enabled=false
+ - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
+ ports:
+ - "9200:9200"
+ volumes:
+ - elasticsearch_data:/usr/share/elasticsearch/data
+
+volumes:
+ elasticsearch_data:
+ driver: local
diff --git a/examples/elasticsearch_search_example.py b/examples/elasticsearch/search_example.py
similarity index 99%
rename from examples/elasticsearch_search_example.py
rename to examples/elasticsearch/search_example.py
index f7285e7cf3..3fcb966dda 100644
--- a/examples/elasticsearch_search_example.py
+++ b/examples/elasticsearch/search_example.py
@@ -35,7 +35,7 @@ def index_sample_documents():
)
# 创建索引 (Create index)
- index_name = "sample_documents"
+ index_name = "documents"
es_manager.create_index(index_name)
# 准备示例文档 (Prepare sample documents)
diff --git a/examples/elasticsearch/test_elasticsearch.sh b/examples/elasticsearch/test_elasticsearch.sh
new file mode 100755
index 0000000000..acf9378540
--- /dev/null
+++ b/examples/elasticsearch/test_elasticsearch.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+echo "==================================="
+echo "Elasticsearch Local Testing Script"
+echo "==================================="
+echo ""
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+NC='\033[0m' # No Color
+
+# Check if Docker is available
+if command -v docker &> /dev/null; then
+ echo -e "${GREEN}✓ Docker found${NC}"
+
+ echo ""
+ echo "Starting Elasticsearch with Docker..."
+ echo "Running: docker-compose -f docker-compose.elasticsearch.yml up -d"
+
+ docker compose -f docker-compose.elasticsearch.yml up -d 2>/dev/null || docker-compose -f docker-compose.elasticsearch.yml up -d
+
+ echo ""
+ echo "Waiting for Elasticsearch to be ready (this may take 30-60 seconds)..."
+
+ # Wait for Elasticsearch to be ready
+ for i in {1..30}; do
+ if curl -s -o /dev/null -w "%{http_code}" http://localhost:9200 | grep -q "200"; then
+ echo -e "${GREEN}✓ Elasticsearch is ready!${NC}"
+ break
+ fi
+ echo -n "."
+ sleep 2
+ done
+ echo ""
+
+else
+ echo -e "${YELLOW}⚠ Docker not found${NC}"
+ echo ""
+ echo "To test Elasticsearch, you need to either:"
+ echo "1. Install Docker: https://docs.docker.com/get-docker/"
+ echo "2. Install Elasticsearch directly:"
+ echo " wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg"
+ echo " 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"
+ echo " sudo apt-get update && sudo apt-get install elasticsearch"
+ echo ""
+ echo "Checking if Elasticsearch is already running on localhost:9200..."
+fi
+
+# Test connection
+echo ""
+echo "Testing Elasticsearch connection..."
+if curl -s -o /dev/null -w "%{http_code}" http://localhost:9200 | grep -q "200"; then
+ echo -e "${GREEN}✓ Elasticsearch is running on http://localhost:9200${NC}"
+
+ # Get cluster info
+ echo ""
+ echo "Cluster info:"
+ curl -s http://localhost:9200 | python3 -m json.tool | head -10
+
+ echo ""
+ echo "Now you can:"
+ echo "1. Run the example script to index sample documents:"
+ echo " ${GREEN}python examples/elasticsearch_search_example.py${NC}"
+ echo ""
+ echo "2. Configure Elasticsearch in the web UI:"
+ echo " - Go to Settings → Search Engines → Elasticsearch"
+ echo " - Set Host URLs to: [\"http://localhost:9200\"]"
+ echo " - Set Index Name to: documents"
+ echo ""
+ echo "3. To stop Elasticsearch (if using Docker):"
+ echo " ${YELLOW}docker compose -f docker-compose.elasticsearch.yml down${NC}"
+
+else
+ echo -e "${RED}✗ Elasticsearch is not accessible on http://localhost:9200${NC}"
+ echo ""
+ echo "Please ensure Elasticsearch is installed and running."
+ exit 1
+fi