proofdb/config/opensearch.php
2026-05-04 13:15:16 +08:00

44 lines
1.4 KiB
PHP

<?php
$bool = static function (string $name, bool $default): bool {
$value = getenv($name);
if ($value === false || $value === '') {
return $default;
}
return in_array(strtolower((string) $value), ['1', 'true', 'yes', 'on'], true);
};
$hosts = getenv('OPENSEARCH_HOSTS') ?: getenv('OPENSEARCH_HOST') ?: 'http://127.0.0.1:9200';
$hosts = array_values(array_filter(array_map('trim', explode(',', $hosts))));
return [
/*
* OpenSearch connection configuration.
*
* Recommended environment variables:
* - OPENSEARCH_HOSTS=http://127.0.0.1:9200
* - OPENSEARCH_USERNAME=admin
* - OPENSEARCH_PASSWORD=...
* - OPENSEARCH_SSL_VERIFY=true
* - OPENSEARCH_INDEX_CHUNKS=proofdb_chunks
*/
'default' => [
'hosts' => $hosts,
'username' => getenv('OPENSEARCH_USERNAME') ?: null,
'password' => getenv('OPENSEARCH_PASSWORD') ?: null,
'ssl_verify' => $bool('OPENSEARCH_SSL_VERIFY', true),
'timeout' => (float) (getenv('OPENSEARCH_TIMEOUT') ?: 30),
'connect_timeout' => (float) (getenv('OPENSEARCH_CONNECT_TIMEOUT') ?: 5),
],
'indices' => [
'chunks' => getenv('OPENSEARCH_INDEX_CHUNKS') ?: 'proofdb_chunks',
],
'bulk' => [
'refresh' => getenv('OPENSEARCH_BULK_REFRESH') ?: 'false',
'chunk_size' => (int) (getenv('OPENSEARCH_BULK_CHUNK_SIZE') ?: 500),
],
];