Skip to content

Commit a31f766

Browse files
authored
Merge pull request #8 from haiwen/support_seafile
feat: indexer as seafile
2 parents 9537df3 + 08c513e commit a31f766

File tree

4 files changed

+117
-43
lines changed

4 files changed

+117
-43
lines changed

manual/api/authentication.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,13 @@ You can generate a token using the following command, for example with aladdin:o
99
echo -n 'aladdin:opensesame' | base64
1010
YWxhZGRpbjpvcGVuc2VzYW1l
1111
```
12-
Note: Basic auth is not secure. If you need to access SeaSearch over the public internet, it is strongly recommended to use HTTPS (e.g., via reverse proxy such as Nginx).
13-
```
14-
"Authorization": "Basic YWRtaW46MTIzNDU2Nzg="
15-
```
1612

17-
## Administrator User
18-
SeaSearch uses accounts to manage API permissions. When the program starts for the first time, an administrator account must be configured through environment variables.
19-
20-
Here is an example of setting the administrator account via shell:
13+
!!! danger
14+
Basic auth is not secure. If you need to access SeaSearch over the public internet, it is strongly recommended to use HTTPS (e.g., via reverse proxy such as Nginx).
15+
2116
```
22-
set INIT_SS_ADMIN_USER=admin
23-
set INIT_SS_ADMIN_PASSWORD=Complexpass#123
17+
"Authorization": "Basic YWRtaW46MTIzNDU2Nzg="
2418
```
25-
!!! tip
26-
In most scenarios, you can use the administrator account to provide access for applications. Only when you need to integrate multiple applications with different permissions, you should create regular users.
27-
2819

2920
## Regular Users
3021
You can create/update users via the API:

manual/config/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
# SeaSearch Configuration
2-
For the official ZincSearch configuration, refer to: [ZincSearch Official Documentation](https://zincsearch-docs.zinc.dev/environment-variables/).
3-
4-
The following configuration options are the ones we’ve extended. All configurations can be set in `.env`.
5-
62
!!! tip
73
After adding new vairables or modifying the existing variables, you have to restart the service to enable changing:
84

manual/deploy/README.md

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
# Deploy
1+
# Deploy SeaSearch
22

3-
## Download the seasearch.yml
3+
This guide provides detailed instructions for deploying SeaSearch, creating user accounts, and utilizing the SeaSearch APIs.
4+
5+
## 1. Download the seasearch.yml
46

57
```bash
68
wget https://haiwen.github.io/seasearch-docs/repo/seasearch.yml
79
```
810

9-
## Modify .env file
11+
## 2. Modify .env file
1012

1113
First, you need to specify the environment variables used by the SeaSearch image in the relevant `.env` file. Some environment variables can be found in [here](../config/README.md). Please add and modify the environment variables (i.e., `<...>`) ​​of the following fields in the `.env` file.
1214

13-
14-
15-
1615
```shell
16+
COMPOSE_FILE='...,seasearch.yml' # ... means other docker-compose yml
17+
1718
# other environment variables in .env file
1819
# For Apple's chip (M2, e.g.), you should use the images with -nomkl tags (i.e., seafileltd/seasearch-nomkl:latest)
1920
SEASEARCH_IMAGE=seafileltd/seasearch:latest
@@ -23,11 +24,97 @@ INIT_SS_ADMIN_USER=<admin-username>
2324
INIT_SS_ADMIN_PASSWORD=<admin-password>
2425
```
2526

26-
## Restart the Service
27+
## 3. Restart the Service
2728

2829
```shell
2930
docker-compose down
3031
docker-compose up
3132
```
3233

33-
Browse seasearch services in [http://127.0.0.1:4080/](http://127.0.0.1:4080/).
34+
!!! success "You can browse SeaSearch services in [http://127.0.0.1:4080/](http://127.0.0.1:4080/)"
35+
36+
## 4. Access API to Create regular user via admin account
37+
38+
### Get auth token:
39+
40+
!!! note
41+
SeaSearch's auth token is using **base64 encode** consist of `username` and `password`, you can check [here](../api/authentication.md) for the whole details
42+
43+
```sh
44+
echo -n 'aladdin:opensesame' | base64
45+
YWxhZGRpbjpvcGVuc2VzYW1l
46+
```
47+
48+
You can use your auth token to access SeaSearch APIs by adding it into `headers`, i.e.,
49+
50+
```json
51+
headers = {
52+
"Authorization": "Basic YWxhZGRpbjpvcGVuc2VzYW1l"
53+
}
54+
```
55+
56+
### Create a regular user
57+
58+
!!! tip
59+
We here just show an example to describe how to use auth token to access SeaSearch APIs, you can check [here](../api/overview.md) for the whole details of SeaSearch APIs.
60+
61+
You can create a regular user by **POST `/api/user`**, e.g.,
62+
63+
```sh
64+
curl -X POST http://127.0.0.1:4080/api/user \
65+
-H "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l" \
66+
-H "Content-Type: application/json" \
67+
-d '{
68+
"_id": "prabhat",
69+
"name": "newusername",
70+
"role": "user",
71+
"password": "Complexpass#123"
72+
}'
73+
```
74+
75+
!!! success
76+
After submitting a **POST** to `/api/user`, you will recive a response
77+
78+
```json
79+
{
80+
"message": "ok",
81+
"id": "prabhat"
82+
}
83+
```
84+
85+
Then, you can remove the initial admin account informations in `.env` (i.e., `INIT_SS_ADMIN_USER`, `INIT_SS_ADMIN_PASSWORD`)
86+
87+
## 5. Access SeaSearch APIs via regular user
88+
89+
### Get auth token
90+
91+
```sh
92+
echo -n 'newusername:Complexpass#123' | base64
93+
bmV3dXNlcm5hbWU6Q29tcGxleHBhc3MjMTIz
94+
```
95+
96+
### Create an index
97+
98+
You can create an index by **PUT `/Index_name`** with related settings, for exmaple:
99+
100+
```sh
101+
curl -X POST http://127.0.0.1:4080/my-index-000001 \
102+
-H "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l" \
103+
-H "Content-Type: application/json" \
104+
-d '{
105+
"settings": {
106+
"number_of_shards": 3,
107+
"number_of_replicas": 2
108+
}
109+
}'
110+
```
111+
112+
response
113+
114+
```json
115+
{
116+
"acknowledged": true,
117+
"shards_acknowledged": true,
118+
"index": "logs"
119+
}
120+
```

manual/repo/seasearch.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ services:
77
ports:
88
- "4080:4080"
99
environment:
10-
- ZINC_FIRST_ADMIN_USER=${INIT_SS_ADMIN_USER}
11-
- ZINC_FIRST_ADMIN_PASSWORD=${INIT_SS_ADMIN_PASSWORD}
10+
- ZINC_FIRST_ADMIN_USER=${INIT_SS_ADMIN_USER:-}
11+
- ZINC_FIRST_ADMIN_PASSWORD=${INIT_SS_ADMIN_PASSWORD:-}
1212
- GIN_MODE=${GIN_MODE:-release}
1313
- ZINC_WAL_ENABLE=${SS_WAL_ENABLE:-true}
14-
- ZINC_STORAGE_TYPE=${SS_STORAGE_TYPE}
15-
- ZINC_SHARD_NUM=${SS_SHARD_NUM}
16-
- ZINC_MAX_OBJ_CACHE_SIZE=${SS_MAX_OBJ_CACHE_SIZE}
17-
- ZINC_S3_ACCESS_ID=${SS_S3_ACCESS_ID}
18-
- ZINC_S3_USE_V4_SIGNATURE=${SS_S3_USE_V4_SIGNATURE}
19-
- ZINC_S3_ACCESS_SECRET=${SS_S3_ACCESS_SECRET}
20-
- ZINC_S3_ENDPOINT=${SS_S3_ENDPOINT}
21-
- ZINC_S3_USE_HTTPS=${SS_S3_USE_HTTPS}
22-
- ZINC_S3_PATH_STYLE_REQUEST=${SS_S3_PATH_STYLE_REQUEST}
23-
- ZINC_S3_AWS_REGION=${SS_S3_AWS_REGION}
24-
- ZINC_SERVER_MODE=${SS_SERVER_MODE}
25-
- ZINC_CLUSTER_ID=${SS_CLUSTER_ID}
26-
- ZINC_ETCD_USERNAME=${SS_ETCD_USERNAME}
27-
- ZINC_ETCD_PASSWORD=${SS_ETCD_PASSWORD}
14+
- ZINC_STORAGE_TYPE=${SS_STORAGE_TYPE:-}
15+
- ZINC_SHARD_NUM=${SS_SHARD_NUM:-}
16+
- ZINC_MAX_OBJ_CACHE_SIZE=${SS_MAX_OBJ_CACHE_SIZE:-}
17+
- ZINC_S3_ACCESS_ID=${SS_S3_ACCESS_ID:-}
18+
- ZINC_S3_USE_V4_SIGNATURE=${SS_S3_USE_V4_SIGNATURE:-}
19+
- ZINC_S3_ACCESS_SECRET=${SS_S3_ACCESS_SECRET:-}
20+
- ZINC_S3_ENDPOINT=${SS_S3_ENDPOINT:-}
21+
- ZINC_S3_USE_HTTPS=${SS_S3_USE_HTTPS:-}
22+
- ZINC_S3_PATH_STYLE_REQUEST=${SS_S3_PATH_STYLE_REQUEST:-}
23+
- ZINC_S3_AWS_REGION=${SS_S3_AWS_REGION:-}
24+
- ZINC_SERVER_MODE=${SS_SERVER_MODE:-}
25+
- ZINC_CLUSTER_ID=${SS_CLUSTER_ID:-}
26+
- ZINC_ETCD_USERNAME=${SS_ETCD_USERNAME:-}
27+
- ZINC_ETCD_PASSWORD=${SS_ETCD_PASSWORD:-}
2828
- ZINC_CLUSTER_PROXY_LOG_DIR=${SS_CLUSTER_PROXY_LOG_DIR:-/opt/seasearch/data/log}
2929
- ZINC_CLUSTER_PROXY_HOST=${SS_CLUSTER_PROXY_HOST:-0.0.0.0}
3030
- ZINC_CLUSTER_PROXY_PORT=${SS_CLUSTER_PROXY_PORT:-4082}
@@ -41,8 +41,8 @@ services:
4141
- ZINC_LOG_DIR=${SS_LOG_DIR:-/opt/seasearch/data/log}
4242
- ZINC_LOG_LEVEL=${SS_LOG_LEVEL:-debug}
4343
- ZINC_PLUGIN_GSE_ENABLE = ${SS_PLUGIN_GSE_ENABLE:-false}
44-
- ZINC_PLUGIN_GSE_DICT_EMBED = ${SS_PLUGIN_GSE_DICT_EMBED}
45-
- ZINC_PLUGIN_GSE_DICT_PATH = ${SS_PLUGIN_GSE_DICT_PATH}
44+
- ZINC_PLUGIN_GSE_DICT_EMBED = ${SS_PLUGIN_GSE_DICT_EMBED:-}
45+
- ZINC_PLUGIN_GSE_DICT_PATH = ${SS_PLUGIN_GSE_DICT_PATH:-}
4646
networks:
4747
- frontend-net
4848
- backend-scheduler-net

0 commit comments

Comments
 (0)