如何在 sphinx 中执行 SQL 加入等效功能?
How do I perform SQL Join equivalent functionality in sphinx?
谁能告诉我如何实现 SQL join in sphinx search 的功能?
我想索引 table1 中的几列和 table2 中的几列。
表格在 MySQL.
您可以只在 sql_query
中使用连接,它只是一个标准的 MySQL 查询,索引器 运行 和索引输出。 MySQL 服务器只需要 运行 它。
sql_query = SELECT id,t.name,o.test FROM table1 t INNER JOIN other o USING (id)
1° 作为 Barryhunter 的回答
sql_query = SELECT t1.id,t1...., t2.... FROM table1 AS t1 INNER JOIN table2 AS t2 ON ....
2°如果一对多
sql_query = SELECT t1.id,t1...., group_concat(t2.foo) ASt 2_foo, . FROM table1 AS t1 INNER JOIN table2 AS t2 ON .... GROUP BY t1.id
group_concat有长度限制,但狮身人面像很棒
sql_query = SELECT t1.id,t1....,. FROM table1 AS t1;
sql_joined_field = t2_foo from query;\
SELECT t2.rel_t1_id , t2.foo\
FROM table2` AS t2\
ORDER by t2.rel_t1_id ASC
由于我英文不好,看这个大概更清楚
http://sphinxsearch.com/docs/current/conf-sql-joined-field.html
sql_joined_field = t2_foo 将再添加一个名为 t2_foo 的 "searchable" 字段。在此字段中,您检索 t2.foo 内容(类似于组连接,但由 space 分隔)
第一列必须是与 sql_query
中的 t1.id 匹配的 ID
必须按 ID ASC 排序
同样的想法,您可以将 mva 用于属性中的多个值
http://sphinxsearch.com/docs/current/conf-sql-attr-multi.html
sql_attr_multi = uint tag from query; \
SELECT id, tag FROM tags
谁能告诉我如何实现 SQL join in sphinx search 的功能? 我想索引 table1 中的几列和 table2 中的几列。
表格在 MySQL.
您可以只在 sql_query
中使用连接,它只是一个标准的 MySQL 查询,索引器 运行 和索引输出。 MySQL 服务器只需要 运行 它。
sql_query = SELECT id,t.name,o.test FROM table1 t INNER JOIN other o USING (id)
1° 作为 Barryhunter 的回答
sql_query = SELECT t1.id,t1...., t2.... FROM table1 AS t1 INNER JOIN table2 AS t2 ON ....
2°如果一对多
sql_query = SELECT t1.id,t1...., group_concat(t2.foo) ASt 2_foo, . FROM table1 AS t1 INNER JOIN table2 AS t2 ON .... GROUP BY t1.id
group_concat有长度限制,但狮身人面像很棒
sql_query = SELECT t1.id,t1....,. FROM table1 AS t1;
sql_joined_field = t2_foo from query;\
SELECT t2.rel_t1_id , t2.foo\
FROM table2` AS t2\
ORDER by t2.rel_t1_id ASC
由于我英文不好,看这个大概更清楚 http://sphinxsearch.com/docs/current/conf-sql-joined-field.html
sql_joined_field = t2_foo 将再添加一个名为 t2_foo 的 "searchable" 字段。在此字段中,您检索 t2.foo 内容(类似于组连接,但由 space 分隔)
第一列必须是与 sql_query
中的 t1.id 匹配的 ID必须按 ID ASC 排序
同样的想法,您可以将 mva 用于属性中的多个值 http://sphinxsearch.com/docs/current/conf-sql-attr-multi.html
sql_attr_multi = uint tag from query; \
SELECT id, tag FROM tags