Skip to content

Commit f77b5a2

Browse files
committed
Add OpenSearch storage configuration support to the interactive setup wizard
1 parent 0acd57a commit f77b5a2

File tree

4 files changed

+119
-8
lines changed

4 files changed

+119
-8
lines changed

scripts/setup/lib/file_ops.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ generate_env_file() {
243243
# keys no longer needed are not left behind in the compose file.
244244
_WIZARD_COMPOSE_LIGHTRAG_KEYS=(
245245
"EMBEDDING_BINDING_HOST" "RERANK_BINDING_HOST" "LLM_BINDING_HOST"
246-
"REDIS_URI" "MONGO_URI" "NEO4J_URI" "MILVUS_URI" "QDRANT_URL" "MEMGRAPH_URI"
246+
"REDIS_URI" "MONGO_URI" "NEO4J_URI" "MILVUS_URI" "QDRANT_URL" "MEMGRAPH_URI" "OPENSEARCH_HOSTS"
247247
"POSTGRES_HOST" "POSTGRES_PORT" "PORT" "HOST" "SSL_CERTFILE" "SSL_KEYFILE"
248248
"WORKING_DIR" "INPUT_DIR"
249249
)
@@ -252,7 +252,7 @@ _managed_service_root_name() {
252252
local service_name="$1"
253253

254254
case "$service_name" in
255-
postgres|neo4j|mongodb|redis|qdrant|memgraph|vllm-embed|vllm-rerank)
255+
postgres|neo4j|mongodb|redis|qdrant|memgraph|opensearch|vllm-embed|vllm-rerank)
256256
printf '%s' "$service_name"
257257
;;
258258
milvus|milvus-etcd|milvus-minio)
@@ -289,6 +289,9 @@ _managed_volume_root_name() {
289289
memgraph_data)
290290
printf 'memgraph'
291291
;;
292+
opensearch_data)
293+
printf 'opensearch'
294+
;;
292295
vllm_rerank_cache)
293296
printf 'vllm-rerank'
294297
;;
@@ -1086,6 +1089,8 @@ generate_docker_compose() {
10861089
;;
10871090
memgraph)
10881091
;;
1092+
opensearch)
1093+
;;
10891094
vllm-rerank)
10901095
;;
10911096
vllm-embed)

scripts/setup/lib/storage_requirements.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare -ag KV_STORAGE_OPTIONS=(
66
"RedisKVStorage"
77
"PGKVStorage"
88
"MongoKVStorage"
9+
"OpenSearchKVStorage"
910
)
1011

1112
declare -ag GRAPH_STORAGE_OPTIONS=(
@@ -14,6 +15,7 @@ declare -ag GRAPH_STORAGE_OPTIONS=(
1415
"PGGraphStorage"
1516
"MongoGraphStorage"
1617
"MemgraphStorage"
18+
"OpenSearchGraphStorage"
1719
)
1820

1921
declare -ag VECTOR_STORAGE_OPTIONS=(
@@ -23,35 +25,41 @@ declare -ag VECTOR_STORAGE_OPTIONS=(
2325
"FaissVectorDBStorage"
2426
"QdrantVectorDBStorage"
2527
"MongoVectorDBStorage"
28+
"OpenSearchVectorDBStorage"
2629
)
2730

2831
declare -ag DOC_STATUS_STORAGE_OPTIONS=(
2932
"JsonDocStatusStorage"
3033
"RedisDocStatusStorage"
3134
"PGDocStatusStorage"
3235
"MongoDocStatusStorage"
36+
"OpenSearchDocStatusStorage"
3337
)
3438

3539
declare -Ag STORAGE_ENV_REQUIREMENTS=(
3640
["JsonKVStorage"]=""
3741
["MongoKVStorage"]="MONGO_URI MONGO_DATABASE"
3842
["RedisKVStorage"]="REDIS_URI"
3943
["PGKVStorage"]="POSTGRES_USER POSTGRES_PASSWORD POSTGRES_DATABASE"
44+
["OpenSearchKVStorage"]="OPENSEARCH_HOSTS OPENSEARCH_USER OPENSEARCH_PASSWORD"
4045
["NetworkXStorage"]=""
4146
["Neo4JStorage"]="NEO4J_URI NEO4J_USERNAME NEO4J_PASSWORD"
4247
["MongoGraphStorage"]="MONGO_URI MONGO_DATABASE"
4348
["MemgraphStorage"]="MEMGRAPH_URI"
4449
["PGGraphStorage"]="POSTGRES_USER POSTGRES_PASSWORD POSTGRES_DATABASE"
50+
["OpenSearchGraphStorage"]="OPENSEARCH_HOSTS OPENSEARCH_USER OPENSEARCH_PASSWORD"
4551
["NanoVectorDBStorage"]=""
4652
["MilvusVectorDBStorage"]="MILVUS_URI MILVUS_DB_NAME"
4753
["PGVectorStorage"]="POSTGRES_USER POSTGRES_PASSWORD POSTGRES_DATABASE"
4854
["FaissVectorDBStorage"]=""
4955
["QdrantVectorDBStorage"]="QDRANT_URL"
5056
["MongoVectorDBStorage"]="MONGO_URI MONGO_DATABASE"
57+
["OpenSearchVectorDBStorage"]="OPENSEARCH_HOSTS OPENSEARCH_USER OPENSEARCH_PASSWORD"
5158
["JsonDocStatusStorage"]=""
5259
["RedisDocStatusStorage"]="REDIS_URI"
5360
["PGDocStatusStorage"]="POSTGRES_USER POSTGRES_PASSWORD POSTGRES_DATABASE"
5461
["MongoDocStatusStorage"]="MONGO_URI MONGO_DATABASE"
62+
["OpenSearchDocStatusStorage"]="OPENSEARCH_HOSTS OPENSEARCH_USER OPENSEARCH_PASSWORD"
5563
)
5664

5765
declare -Ag STORAGE_DB_TYPES=(
@@ -69,4 +77,8 @@ declare -Ag STORAGE_DB_TYPES=(
6977
["MemgraphStorage"]="memgraph"
7078
["MilvusVectorDBStorage"]="milvus"
7179
["QdrantVectorDBStorage"]="qdrant"
80+
["OpenSearchKVStorage"]="opensearch"
81+
["OpenSearchGraphStorage"]="opensearch"
82+
["OpenSearchVectorDBStorage"]="opensearch"
83+
["OpenSearchDocStatusStorage"]="opensearch"
7284
)

scripts/setup/setup.sh

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ STORAGE_SERVICES=(
6060
"milvus"
6161
"qdrant"
6262
"memgraph"
63+
"opensearch"
6364
)
6465
DEFAULT_RUNTIME_TARGET="host"
6566
COMPOSE_LIGHTRAG_WORKING_DIR="/app/data/rag_storage"
@@ -434,6 +435,11 @@ set_managed_service_compose_overrides() {
434435
set_compose_override "MEMGRAPH_URI" "bolt://memgraph:7687"
435436
fi
436437
;;
438+
opensearch)
439+
if [[ -z "${COMPOSE_ENV_OVERRIDES[OPENSEARCH_HOSTS]+set}" ]]; then
440+
set_compose_override "OPENSEARCH_HOSTS" "opensearch:9200"
441+
fi
442+
;;
437443
esac
438444
}
439445

@@ -472,7 +478,7 @@ prepare_compose_runtime_overrides() {
472478
fi
473479
fi
474480

475-
for root_service in postgres neo4j mongodb redis milvus qdrant memgraph; do
481+
for root_service in postgres neo4j mongodb redis milvus qdrant memgraph opensearch; do
476482
if [[ -n "${DOCKER_SERVICE_SET[$root_service]+set}" ]]; then
477483
set_managed_service_compose_overrides "$root_service"
478484
fi
@@ -485,7 +491,8 @@ prepare_compose_runtime_overrides() {
485491
"NEO4J_URI" \
486492
"MILVUS_URI" \
487493
"QDRANT_URL" \
488-
"MEMGRAPH_URI"; do
494+
"MEMGRAPH_URI" \
495+
"OPENSEARCH_HOSTS"; do
489496
if [[ -n "${COMPOSE_ENV_OVERRIDES[$key]+set}" ]]; then
490497
continue
491498
fi
@@ -557,7 +564,7 @@ restore_storage_docker_services_from_env() {
557564
local db_type
558565
local marker_key=""
559566
local service_name=""
560-
local db_types=("postgresql" "neo4j" "mongodb" "redis" "milvus" "qdrant" "memgraph")
567+
local db_types=("postgresql" "neo4j" "mongodb" "redis" "milvus" "qdrant" "memgraph" "opensearch")
561568

562569
for db_type in "${db_types[@]}"; do
563570
marker_key="$(storage_deployment_marker_key "$db_type")"
@@ -917,7 +924,7 @@ storage_service_name_for_db_type() {
917924
postgresql)
918925
printf 'postgres'
919926
;;
920-
neo4j|mongodb|redis|milvus|qdrant|memgraph)
927+
neo4j|mongodb|redis|milvus|qdrant|memgraph|opensearch)
921928
printf '%s' "$db_type"
922929
;;
923930
*)
@@ -951,6 +958,9 @@ storage_deployment_marker_key() {
951958
memgraph)
952959
printf 'LIGHTRAG_SETUP_MEMGRAPH_DEPLOYMENT'
953960
;;
961+
opensearch)
962+
printf 'LIGHTRAG_SETUP_OPENSEARCH_DEPLOYMENT'
963+
;;
954964
*)
955965
printf ''
956966
;;
@@ -995,7 +1005,7 @@ persist_storage_deployment_choice() {
9951005
clear_unused_storage_deployment_markers() {
9961006
local db_type
9971007

998-
for db_type in postgresql neo4j mongodb redis milvus qdrant memgraph; do
1008+
for db_type in postgresql neo4j mongodb redis milvus qdrant memgraph opensearch; do
9991009
if [[ -z "${REQUIRED_DB_TYPES[$db_type]+set}" ]]; then
10001010
persist_storage_deployment_choice "$db_type" "no"
10011011
fi
@@ -1030,6 +1040,9 @@ collect_database_config() {
10301040
memgraph)
10311041
collect_memgraph_config "$default_docker"
10321042
;;
1043+
opensearch)
1044+
collect_opensearch_config "$default_docker"
1045+
;;
10331046
*)
10341047
echo "Unknown database type: $db_type" >&2
10351048
return 1
@@ -1370,6 +1383,46 @@ collect_memgraph_config() {
13701383
fi
13711384
}
13721385

1386+
collect_opensearch_config() {
1387+
local default_docker="${1:-no}"
1388+
local use_docker="no"
1389+
local hosts user password
1390+
1391+
if [[ "$default_docker" == "yes" ]]; then
1392+
if confirm_default_yes "Run OpenSearch locally via Docker?"; then
1393+
use_docker="yes"
1394+
fi
1395+
else
1396+
if confirm_default_no "Run OpenSearch locally via Docker?"; then
1397+
use_docker="yes"
1398+
fi
1399+
fi
1400+
1401+
if [[ "$use_docker" == "yes" ]]; then
1402+
add_docker_service "opensearch"
1403+
hosts="$(prefer_local_service_uri "${ENV_VALUES[OPENSEARCH_HOSTS]:-}" "localhost:9200" "opensearch" "localhost" "127.0.0.1" "0.0.0.0")"
1404+
else
1405+
hosts="${ENV_VALUES[OPENSEARCH_HOSTS]:-localhost:9200}"
1406+
fi
1407+
1408+
hosts="$(prompt_with_default "OpenSearch hosts" "$hosts")"
1409+
user="$(prompt_with_default "OpenSearch user" "${ENV_VALUES[OPENSEARCH_USER]:-admin}")"
1410+
password="$(prompt_secret_with_default "OpenSearch password: " "${ENV_VALUES[OPENSEARCH_PASSWORD]:-LightRAG2026_!@}")"
1411+
1412+
ENV_VALUES["OPENSEARCH_HOSTS"]="$hosts"
1413+
ENV_VALUES["OPENSEARCH_USER"]="$user"
1414+
ENV_VALUES["OPENSEARCH_PASSWORD"]="$password"
1415+
ENV_VALUES["OPENSEARCH_USE_SSL"]="${ENV_VALUES[OPENSEARCH_USE_SSL]:-true}"
1416+
ENV_VALUES["OPENSEARCH_VERIFY_CERTS"]="${ENV_VALUES[OPENSEARCH_VERIFY_CERTS]:-false}"
1417+
ENV_VALUES["OPENSEARCH_USE_PPL_GRAPHLOOKUP"]="${ENV_VALUES[OPENSEARCH_USE_PPL_GRAPHLOOKUP]:-false}"
1418+
1419+
if [[ "$use_docker" == "yes" ]]; then
1420+
set_compose_override "OPENSEARCH_HOSTS" "opensearch:9200"
1421+
else
1422+
set_compose_override "OPENSEARCH_HOSTS" ""
1423+
fi
1424+
}
1425+
13731426
clear_bedrock_credentials() {
13741427
unset 'ENV_VALUES[AWS_ACCESS_KEY_ID]'
13751428
unset 'ENV_VALUES[AWS_SECRET_ACCESS_KEY]'
@@ -2244,7 +2297,7 @@ finalize_base_setup() {
22442297
env_storage_flow() {
22452298
local env_file="${REPO_ROOT}/.env"
22462299
local db_type
2247-
local db_order=("postgresql" "neo4j" "mongodb" "redis" "milvus" "qdrant" "memgraph")
2300+
local db_order=("postgresql" "neo4j" "mongodb" "redis" "milvus" "qdrant" "memgraph" "opensearch")
22482301

22492302
if [[ ! -f "$env_file" ]]; then
22502303
format_error "No .env file found." "Run 'make env-base' first to configure LLM and embedding."
@@ -2640,6 +2693,10 @@ validate_env_file() {
26402693
format_error "Invalid POSTGRES_PORT" "Use a port between 1 and 65535."
26412694
errors=1
26422695
fi
2696+
if [[ -n "${ENV_VALUES[OPENSEARCH_HOSTS]:-}" ]] && [[ -z "${ENV_VALUES[OPENSEARCH_HOSTS]}" ]]; then
2697+
format_error "Empty OPENSEARCH_HOSTS" "Set it to host:port (e.g. localhost:9200)."
2698+
errors=1
2699+
fi
26432700
if ((errors != 0)); then
26442701
return 1
26452702
fi
@@ -2752,6 +2809,16 @@ security_check_env_file() {
27522809
fi
27532810
fi
27542811

2812+
if [[ -n "${ENV_VALUES[OPENSEARCH_PASSWORD]:-}" ]]; then
2813+
local os_pass="${ENV_VALUES[OPENSEARCH_PASSWORD]}"
2814+
if [[ "$os_pass" == "admin" || "$os_pass" == "LightRAG2026_!@" ]]; then
2815+
report_security_issue \
2816+
"OPENSEARCH_PASSWORD uses a well-known default value." \
2817+
"Set a unique, strong password for the OpenSearch admin account."
2818+
findings=$((findings + 1))
2819+
fi
2820+
fi
2821+
27552822
if ((findings == 0)); then
27562823
log_success "No obvious security issues found in ${env_file}."
27572824
return 0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
opensearch:
2+
image: opensearchproject/opensearch:3
3+
environment:
4+
- discovery.type=single-node
5+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:?missing}
6+
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
7+
ports:
8+
- "9200:9200"
9+
ulimits:
10+
memlock:
11+
soft: -1
12+
hard: -1
13+
nofile:
14+
soft: 65536
15+
hard: 65536
16+
volumes:
17+
- opensearch_data:/usr/share/opensearch/data
18+
healthcheck:
19+
test:
20+
- CMD-SHELL
21+
- 'PORT_HEX="$(printf ''%04X'' 9200)"; cat /proc/net/tcp /proc/net/tcp6 2>/dev/null | grep -q ":$${PORT_HEX} "'
22+
interval: 10s
23+
timeout: 5s
24+
retries: 30
25+
start_period: 30s
26+
stop_grace_period: 30s
27+
restart: unless-stopped

0 commit comments

Comments
 (0)