Add vector-stores module: one dataset through VectorStore on pgvector, Redis, Qdrant and Elasticsearch
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JXVi2GMQ7bR5EmbUFdDj7N
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Starts the four vector stores the benchmark compares, with no Docker:
|
||||
# pgvector 127.0.0.1:5441 apt: postgresql-16 + postgresql-16-pgvector (runs as the postgres user)
|
||||
# Redis Stack 127.0.0.1:6392 tarball: redis-stack-server (Redis + RediSearch module)
|
||||
# Qdrant 127.0.0.1:6334 tarball: single static binary (gRPC 6334, REST 6333)
|
||||
# Elasticsearch 127.0.0.1:9200 tarball: single node, security off (runs as the 'es' user)
|
||||
# TOOLS defaults to /tmp/tools; see the article for the exact download URLs.
|
||||
set -euo pipefail
|
||||
TOOLS="${TOOLS:-/tmp/tools}"
|
||||
RUN=/tmp/vs-run; mkdir -p "$RUN"; chmod 777 "$RUN"
|
||||
listening() { (exec 3<>/dev/tcp/127.0.0.1/$1) 2>/dev/null; }
|
||||
|
||||
# ---- pgvector -------------------------------------------------------------------------------
|
||||
PGBIN=/usr/lib/postgresql/16/bin; PGDATA=$RUN/pgdata; PGPORT=5441
|
||||
if ! listening $PGPORT; then
|
||||
id postgres >/dev/null 2>&1
|
||||
rm -rf "$PGDATA"; mkdir -p "$PGDATA"; chown postgres "$PGDATA"
|
||||
su postgres -c "$PGBIN/initdb -D $PGDATA -A trust >/dev/null"
|
||||
su postgres -c "$PGBIN/pg_ctl -D $PGDATA -o '-p $PGPORT -c listen_addresses=127.0.0.1 -c unix_socket_directories=$RUN' -l $RUN/pg.log -w start >/dev/null"
|
||||
su postgres -c "psql -h $RUN -p $PGPORT -d postgres -c \"CREATE ROLE vs LOGIN PASSWORD 'vs' SUPERUSER\" -c 'CREATE DATABASE vsdb OWNER vs'" >/dev/null
|
||||
fi
|
||||
|
||||
# ---- Redis Stack ----------------------------------------------------------------------------
|
||||
RS="$TOOLS/redis-stack-server-7.4.0-v8"
|
||||
if ! listening 6392; then
|
||||
mkdir -p "$RUN/redis"
|
||||
"$RS/bin/redis-server" --port 6392 --bind 127.0.0.1 --dir "$RUN/redis" --save "" --daemonize yes \
|
||||
--loadmodule "$RS/lib/redisearch.so" --loadmodule "$RS/lib/rejson.so" --logfile "$RUN/redis.log" >/dev/null
|
||||
fi
|
||||
|
||||
# ---- Qdrant ---------------------------------------------------------------------------------
|
||||
if ! listening 6334; then
|
||||
mkdir -p "$RUN/qdrant"
|
||||
( cd "$RUN/qdrant" && QDRANT__STORAGE__STORAGE_PATH="$RUN/qdrant/storage" QDRANT__SERVICE__HOST=127.0.0.1 \
|
||||
setsid nohup "$TOOLS/qdrant/qdrant" > "$RUN/qdrant.log" 2>&1 < /dev/null & )
|
||||
fi
|
||||
|
||||
# ---- Elasticsearch --------------------------------------------------------------------------
|
||||
ES="$TOOLS/$(ls "$TOOLS" | grep -m1 '^elasticsearch-')"
|
||||
if ! listening 9200; then
|
||||
id es >/dev/null 2>&1 || useradd -m es
|
||||
chown -R es "$ES"
|
||||
su es -c "ES_JAVA_OPTS='-Xms1g -Xmx1g' $ES/bin/elasticsearch -d -p $RUN/es.pid \
|
||||
-E xpack.security.enabled=false -E discovery.type=single-node -E http.host=127.0.0.1 \
|
||||
-E path.data=$RUN/esdata -E path.logs=$RUN/eslogs" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
for i in $(seq 1 90); do
|
||||
curl -s -o /dev/null 127.0.0.1:9200 && curl -s -o /dev/null 127.0.0.1:6333 && break; sleep 2
|
||||
done
|
||||
# On a disk that is >90% full Elasticsearch silently refuses to allocate shards (see output/13-es-disk-watermark.txt).
|
||||
curl -s -X PUT -H 'Content-Type: application/json' 127.0.0.1:9200/_cluster/settings \
|
||||
-d '{"persistent":{"cluster.routing.allocation.disk.threshold_enabled":false}}' >/dev/null || true
|
||||
echo "pgvector :$PGPORT (vsdb/vs/vs), redis-stack :6392, qdrant :6334 (REST :6333), elasticsearch :9200"
|
||||
Reference in New Issue
Block a user