Skip to content

The backend service for search base on Python. 基于python的Startalk搜索功能

License

Notifications You must be signed in to change notification settings

startalkIM/search

 
 

Repository files navigation

搜索系统


前提:

  • libffi-devel sudo yum -y install libffi-devel
  • openssl version >= 1.02
  • python3.7及以上, 以3.9.2为例
        cd /startalk/download && wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
        tar -zxvf Python-3.9.2.tgz
        cd Python-3.9.2
        ./configure --prefix=/startalk/python392
        make && make install
  • 添加到bash_profile
vim ~/.bash_profile
        PYTHONPATH=/startalk/python392
        PATH=$PATH:$PYTHONPATH/bin
:wq
source ~/.bash_profile
  • (可选) 建议使用virtualenv部署模块所需环境

升级pip

/startalk/python392/bin/python3.9 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

下载安装virtualenv

pip3.9 install -U virtualenv -i https://pypi.tuna.tsinghua.edu.cn/simple 

创建虚拟环境

cp -rf /startalk/download/search /startalk/ && cd /startalk/search && virtualenv --system-site-packages -p python3.9 ./venv

启动环境

source venv/bin/activate

安装:

  • 配置conf/configure.ini
  • 安装依赖, 使用-i 国内源下载项目
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
  • 启动项目
supervisord -c /startalk/search/conf/supervisor.conf

确认服务正常:

tail -100f /startalk/search/log/access.log

请求

POST( application/json ):

  • 传参:
        {
            "key":"he",
            "qtalkId":"jingyu.he",
            "cKey":"xxxxxxmyckey",
            "action":"",
            "start":0,
            "length":10
        }
            *大小写重要, 都是string

            key     :  搜索关键字
            qtalkId :  搜索人userid@domain
            cKey    :  xxxxxxxx ckey规则
            action :  63:all 32:file 24:history 6:group 1:user //二进制111111 搜文件 搜群聊 搜单聊 共同群组 群组 用户 搜哪个哪个就个位就是1
            start   :  偏移量
            length  :  长度
  • 返回:
application / json
{
    "data": [
        {
            "defaultportrait": "default_single_avatar_url.png",
            "groupId": "Q01",
            "groupLabel": "联系人列表",
            "groupPriority": 0,
            "hasMore": true,
            "info": [
                {
                    "content": "/dep1/dep2",
                    "icon": "aaa.jpg",
                    "label": "个人签名",
                    "name": "张三",
                    "qtalkname": "gtouchgogo",
                    "uri": "gtouchgogo@domain"
                }
            ],
            "todoType": 0
        },
        {
            "defaultportrait": "default_avatar_url.png",
            "groupId": "Q02",
            "groupLabel": "群组列表",
            "groupPriority": 0,
            "hasMore": false,
            "info": [
                {
                    "content": "群公告",
                    "icon": "bbb.png",
                    "label": "张三,李四",
                    "uri": "weffijw328f2@conference.domain"
                }
            ],
            "todoType": 1
        },
        {
            "defaultportrait": "default_avatar_url.png",
            "groupId": "Q07",
            "groupLabel": "共同群组",
            "groupPriority": 0,
            "hasMore": false,
            "info": [
                {
                    "content": "群公告",
                    "icon": "bbb.png",
                    "label": "张三,李四",
                    "uri": "weffijw328f2@conference.domain"
                }
            ],
            "todoType": 1
        }
    ],
    "errcode": 0,
    "msg": ""
}

其它:

  • 配置文件: search/conf/configure.ini
  • 日志配置文件: search/utils/logger_conf.py
  • 日志文件: search/log/yyyy_mm_dd_{module}.log)
    为了避免日志过于冗长,日志会打印当前请求用户的userid+ckey并且打印上一个ip的最后一次请求

About

The backend service for search base on Python. 基于python的Startalk搜索功能

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.9%
  • HTML 2.4%
  • Other 0.7%