# indexer **Repository Path**: indexea/indexer ## Basic Information - **Project Name**: indexer - **Description**: indexer 是一个将数据(支持包括 SQL 等多种数据库、文件目录、队列)自动同步到 indexea 的工具 - **Primary Language**: Rust - **License**: MIT - **Default Branch**: master - **Homepage**: https://indexea.com - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2022-10-24 - **Last Updated**: 2024-08-14 ## Categories & Tags **Categories**: search-engine **Tags**: None ## README ## indexer `indexer` 是一个实现将客户数据(支持包括 SQL 等多种数据库、文件目录、队列)自动同步到 `indexea` 的工具。 `indexer` 采用 rust 语言开发,体积小、支持跨平台,简单轻便,资源占用少,同时对业务系统的侵入很小。 `indexer` 提供非常灵活的配置 (`indexer.yml`),以非常高效方式将业务数据同步到 `indexea`。 该工具基于 MIT 许可证开源,开源地址:[https://gitee.com/indexea/indexer](https://gitee.com/indexea/indexer) ## 使用说明 ### 编译 安装 rust 环境 ```shell curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` 配置 rust 镜像库(可选) $HOME/.cargo/config ```toml [source.crates-io] registry = "https://github.com/rust-lang/crates.io-index" replace-with = 'tuna' [source.tuna] registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" ``` 下载源码并编译 ```shell git clone https://gitee.com/indexea/indexer.git cd indexer cargo build --release ``` ### 配置文件 `indexer` 使用 YAML 文件(`indexer.yml`)进行灵活的自定义配置,配置包括三部分内容: | 序号 | 配置名 | 配置说明 | 其他说明 | |----|------------|--------------|------------------------------------------------| | 1 | datasource | 数据源定义 | 允许配置多个数据库,当前支持 MySQL 和 Postgres | | 2 | endpoint | Indexea 服务配置 | 只能配置单个服务,如果需要使用多个服务,可以运行多个 indexer 的实例 | | 3 | tasks | 同步任务配置 | 配置 datasource 的数据如何同步到 endpoint 中,可以配置一到多个同步任务 | **indexer.yml** ```yaml datasource: mydb: # datasource name source: "mysql" # mysql,postgres,oracle url: "mysql://account:passwd@localhost:3306/mydb" endpoint: url: "https://api.indexea.com/v1/" # Indexea Gateway API oauth_url: "https://api.indexea.com/oauth" # Indexea Gateway OAuth client_id: "smxuk5rvrfjkzhrf1244" # client id (详见应用设置的第三方应用管理) client_secret: "gqee9yh2igplhkb9deq9ngqmufu19ivaq4mp2492" # client secret indices: repositories: # index name app: "tw6mi8il" # app ient index: 1005 # index id blogs: app: "tw6mi8il" index: 1006 tasks: repositories: # task name datasource: "mydb" # datasource name, refer to $datasource.mydb index: "repositories" # index name, refer to $endpoint.indices.repositories table: "repositories" # table name primary: "id" # primary field name of table fields: tags: split: # split field value to multi values new_field_name: "tags" # 新字段名(可选) delimiter: "," # 字段值分隔符 type: string # 字段值类型, string or (integer, long, number) or (float, double) intro: html_strip: # 去除 html 标签 new_field_name: "detail" # 新字段名(可选) extract_images_to_field: "images" # 提取图片到新字段(可选) detail: markdown: # markdown 转为纯文本 new_field_name: "detail" # 新字段名 extract_images_to_field: "images" # 提取图片到新字段(可选) extract_summary_to_field: "summary" # 提取摘要到新字段(可选,速度非常慢,生成一次的时间在几百毫秒) summary_sentences: 2 # 摘要句子数(可选) interval: 1000 # check interval in mills-second blogs: datasource: "mydb" index: "blogs" table: "blogs" primary: "id" sql: "SELECT b.*, a.name AS author_name FROM blogs b LEFT JOIN authors a ON b.author = a.id" ##指定 SQL ,否则默认为 SELECT * FROM