Skip to content

Commit

Permalink
翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
vergil-lai committed Oct 22, 2024
1 parent d566cd8 commit 919ae3e
Show file tree
Hide file tree
Showing 27 changed files with 591 additions and 526 deletions.
32 changes: 16 additions & 16 deletions Extensions/FEDERATED.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# FEDERATED

With the MySQL FEDERATED engine, you can connect to a local or remote Manticore instance from MySQL/MariaDB and perform search queries.
使用 MySQL FEDERATED 引擎,您可以从 MySQL/MariaDB 连接到本地或远程的 Manticore 实例并执行搜索查询。

## Using FEDERATED
## 使用 FEDERATED

An actual Manticore query can't be used directly with the FEDERATED engine and must be "proxied" (sent as a string in a column) due to the FEDERATED engine's limitations and the fact that Manticore implements custom syntax like the [MATCH](../Searching/Full_text_matching/Basic_usage.md) clause.
由于 FEDERATED 引擎的限制,以及 Manticore 实现了自定义语法(例如 [MATCH](../Searching/Full_text_matching/Basic_usage.md) 子句),因此实际的 Manticore 查询不能直接与 FEDERATED 引擎一起使用,必须作为字符串通过列 "代理" 发送。

To search via `FEDERATED`, you first need to create a FEDERATED engine table. The Manticore query will be included in a `query` column in the `SELECT` performed over the FEDERATED table.
要通过 `FEDERATED` 进行搜索,首先需要创建一个 FEDERATED 引擎表。Manticore 查询将包含在对 FEDERATED 表执行的 `SELECT` 查询的 `query` 列中。

<!-- example create federated -->
Creating a FEDERATED-compatible MySQL table:
创建一个兼容 FEDERATEDMySQL 表:


<!-- intro -->
Expand Down Expand Up @@ -37,7 +37,7 @@ Query OK, 0 rows affected (0.00 sec)
<!-- end -->

<!-- example select federated -->
Query FEDERATED compatible table:
查询与 FEDERATED 兼容的表:


<!-- intro -->
Expand All @@ -61,35 +61,35 @@ SELECT * FROM t1 WHERE query='SELECT * FROM movies WHERE MATCH (\'pie\')';
```
<!-- end -->

The only fixed mapping is the `query` column. It is mandatory and must be the only column with a table attached.
唯一的固定映射是 `query` 列。它是强制性的,并且必须是附加了表的唯一列。

The Manticore table linked via `FEDERATED` **must** be a physical table (plain or real-time).
通过 `FEDERATED` 连接的 Manticore 表 **必须** 是物理表(普通表或实时表)。

The FEDERATED table should have columns with the same names as the remote Manticore table attributes since they will be bound to the attributes provided in the Manticore result set by name. However, it might map only some attributes, not all of them.
FEDERATED 表应具有与远程 Manticore 表属性相同名称的列,因为它们将通过名称与 Manticore 结果集中提供的属性绑定。但是,它可能只映射某些属性,而不是全部属性。

Manticore server identifies a query from a FEDERATED client by the user name "FEDERATED". The `CONNECTION` string parameter is used to specify the Manticore host, SQL port, and tables for queries coming through the connection. The connection string syntax is as follows:
Manticore 服务器通过用户名 "FEDERATED" 来识别来自 FEDERATED 客户端的查询。`CONNECTION` 字符串参数用于指定 Manticore 主机、SQL 端口和通过连接传递查询的表。连接字符串的语法如下:

```ini
CONNECTION="mysql://FEDERATED@HOST:PORT/DB/TABLENAME"
```

Since Manticore doesn't have the concept of a database, the `DB` string can be random as it will be ignored by Manticore, but MySQL requires a value in the `CONNECTION` string definition. As seen in the example, the full `SELECT` SQL query should be placed in a WHERE clause against the `query` column.
由于 Manticore 没有数据库的概念,`DB` 字符串可以是任意的,因为 Manticore 将忽略它,但 MySQL 要求在 `CONNECTION` 字符串定义中包含该值。如示例中所示,完整的 `SELECT` SQL 查询应放置在针对 `query` 列的 WHERE 子句中。

Only the `SELECT` statement is supported, not `INSERT`, `REPLACE`, `UPDATE`, or `DELETE`.
仅支持 `SELECT` 语句,不支持 `INSERT``REPLACE``UPDATE` `DELETE`

### FEDERATED tips
### FEDERATED 提示

One **very important** note is that it is **much** more efficient to allow Manticore to perform sorting, filtering, and slicing the result set than to increase the max matches count and use WHERE, ORDER BY, and LIMIT clauses on the MySQL side. This is for two reasons. First, Manticore implements a number of optimizations and performs better than MySQL for these tasks. Second, less data needs to be packed by searchd, transferred, and unpacked between Manticore and MySQL.
一个 **非常重要的** 注意事项是,与其增加最大匹配数并在 MySQL 端使用 WHEREORDER BY LIMIT 子句,不如让 Manticore 负责执行排序、过滤和对结果集的切片操作。这有两个原因。首先,Manticore 实现了许多优化,并且在这些任务上比 MySQL 执行得更好。其次,在 Manticore MySQL 之间传递的数据量会减少,因此数据打包、传输和解包的负担也会减轻。

<!-- example federated join -->
JOINs can be performed between a FEDERATED table and other MySQL tables. This can be used to retrieve information that is not stored in a Manticore table.
可以在 FEDERATED 表和其他 MySQL 表之间执行 JOIN 操作。这可用于检索未存储在 Manticore 表中的信息。


<!-- intro -->
##### SQL:

<!-- request SQL -->
##### Query to JOIN MySQL based table with FEDERATED table served by Manticore:
##### 查询将 MySQL 基于表的 JOIN 与 Manticore 提供的 FEDERATED 表结合:

```sql
SELECT t1.id, t1.year, comments.comment FROM t1 JOIN comments ON t1.id=comments.post_id WHERE query='SELECT * FROM movies WHERE MATCH (\'pie\')';
Expand Down
Loading

0 comments on commit 919ae3e

Please sign in to comment.