Skip to content

Commit 2290829

Browse files
committed
fix zinc search #103
1 parent d34f89c commit 2290829

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

Docker.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ wget https://raw.githubusercontent.com/tgbot-collection/SearchGram/master/docker
1212

1313
In this `docker-compose.yml`, you need to decide which search engine to use, available options are:
1414

15-
* MeiliSearch
15+
* MeiliSearch: default option
1616
* MongoDB
1717
* ZincSearch
1818

1919
Comment out the search engine you don't want to use.
2020

21+
> if you're unable to run zinc, please change data folder permission `chown -R 10001:10001 ./sg_data/zinc`
22+
2123
# 2. (Optional) Prepare the Encrypted Data Volume
2224

2325
For added security, it's recommended to use an encrypted data volume.
@@ -99,7 +101,7 @@ umount /dev/mapper/sg_data
99101
cryptsetup luksClose sg_data
100102
````
101103

102-
# 3. Obtain APP_ID, APP_HASH, and Bot Token
104+
# 3. get APP_ID, APP_HASH, and Bot Token
103105

104106
To get started with SearchGram, you'll need to
105107
@@ -111,8 +113,6 @@ To get started with SearchGram, you'll need to
111113
112114
All the environment variables are stored in `env/gram.env` and you can see the comments in `config.py` for more details.
113115
114-
Make sure they're correct before you start the container. You can cross-check them with `docker-compose.yml`
115-
116116
```shell
117117
118118
An example of `env/gram.env` is shown below:
@@ -123,7 +123,7 @@ TOKEN=token
123123
APP_ID=id
124124
APP_HASH=hash
125125
OWNER_ID=your user_id
126-
MEILI_MASTER_KEY=token
126+
ENGINE=meili # meili, mongo, zinc
127127
```
128128
129129
# 5. Login to client

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ see [Max indexing memory](https://www.meilisearch.com/docs/learn/configuration/i
8282
# Installation
8383
8484
**Note: Because chat history should be kept private, we do not offer any public bots.**
85-
**To learn how to use SearchGram in Docker, please refer to the [Docker.md](Docker.md)**
8685
87-
Please follow the steps below to install SearchGram:
86+
Please follow the steps below to install SearchGram on your own server.
87+
88+
This guide will show you how to install SearchGram with our default search engine, MeiliSearch.
89+
90+
**To learn how to use SearchGram in Docker with different search engine, please refer to the [Docker.md](Docker.md)**
8891
8992
## 1. Preparation
9093

docker-compose.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ services:
4343
image: public.ecr.aws/zinclabs/zincsearch:latest
4444
environment:
4545
ZINC_DATA_PATH: "/data"
46-
# GIN_MODE: "release"
47-
ZINC_FIRST_ADMIN_USER: "root"
48-
ZINC_FIRST_ADMIN_PASSWORD: "root"
4946
env_file:
5047
- env/gram.env
5148
volumes:

searchgram/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def parse_and_search(text, page=1) -> Tuple[str, InlineKeyboardMarkup | None]:
146146
user = args.user
147147
keyword = args.keyword
148148
mode = args.mode
149+
logging.info("Search keyword: %s, type: %s, user: %s, page: %s, mode: %s", keyword, _type, user, page, mode)
149150
results = tgdb.search(keyword, _type, user, page, mode)
150151
text = parse_search_results(results)
151152
if not text:

searchgram/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
# available values: meili, mongo, zinc, default: meili
2626
ENGINE = os.getenv("ENGINE", "meili").lower()
2727

28+
# If you want to use Zinc as search engine, you need to set username and password
2829
ZINC_HOST = os.getenv("ZINC_HOST", "http://zinc:4080")
29-
ZINC_USER = os.getenv("ZINC_USER", "root")
30-
ZINC_PASS = os.getenv("ZINC_PASS", "root")
30+
ZINC_USER = os.getenv("ZINC_FIRST_ADMIN_USER", "root")
31+
ZINC_PASS = os.getenv("ZINC_FIRST_ADMIN_PASSWORD", "root")
3132

3233
####################################
3334
# Your own user id, for example: 260260121

searchgram/zinc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def search(self, keyword, _type=None, user=None, page=1, mode=None) -> dict:
7373
total_hits = results.hits.total.value
7474
total_pages = math.ceil(total_hits / 10)
7575
return {
76-
"hits": results.hits.hits,
76+
"hits": [i.source for i in results.hits.hits],
7777
"query": keyword,
7878
"hitsPerPage": 10,
7979
"page": page,

0 commit comments

Comments
 (0)