简体   繁体   English

将MySQL转换为Sphinx搜索平台

[英]Converting MySQL to a Sphinx Search Platform

Currently working on an in-house search engine for over 12 GB / month of MySQL data. 目前正在使用内部搜索引擎来处理每月超过12 GB的MySQL数据。

We currently have two tables, practice prescribing, and practice information. 当前,我们有两个表格,练习处方和练习信息。

Both tables contain a column, practice number which identifies the practice information with their prescribing information. 这两个表均包含一列实践编号,该列标识了实践信息及其处方信息。

I'm trying to migrate the system from MySQL searching to Sphinx Search. 我正在尝试将系统从MySQL搜索迁移到Sphinx Search。

The issue I'm having is the format of the practice number is STR:NUM:NUM. 我遇到的问题是练习编号的格式为STR:NUM:NUM。

Sphinx Search says that is an invalid or Null ID format and a ID needs to be just NUM. Sphinx Search说这是无效或Null的ID格式,并且ID只能为NUM。

An example of our current ID's is YV0091 which will have corresponding data in both tables. 当前ID的一个示例是YV0091,它将在两个表中都有相应的数据。

The ID's cannot be changed or manipulated due to them being a standardised ID in our industry. 由于ID是我们行业中的标准化ID,因此无法更改或操作。

What should I do to get around this? 我应该怎么做才能解决这个问题?

Well the document-id itself, in effects Sphinxes 'primary key' does need to be a simple integer. 好吧,文档ID本身,实际上是Sphinxes的“主键”必须是一个简单的整数。 But it doesnt need to match an actual column in your database. 但是它不需要匹配数据库中的实际列。 (bit like in innodb, if dont have in integer primary key, it will create a 'rowid' internally) (就像innodb中的位,如果没有整数主键,它将在内部创建一个“ rowid”)

Alas sphinx doesnt have a 'autoincrement' style way of allocating the id, so need to contrive it yourself. 遗憾的是,狮身人面像没有分配ID的“自动递增”样式,因此您需要自己设计。 For example using a mysql user-variable... 例如使用mysql用户变量...

sql_query_pre = SET @rowid:=1
sql_query = SELECT @rowid:=@rowid+1 as id, practice_id, name, ... 
sql_attr_string = practice_id

... also includes putting the your practice id as an attribute . ...还包括将您的练习ID作为属性 This means can still get it in queries, eg rather than using SELECT id FROM ... in sphinxql, can just do SELECT practice_id FROM ... instead. 这意味着仍然可以在查询中获取它,例如,而不是在sphinxql中使用SELECT id FROM ... ,而可以只执行SELECT practice_id FROM ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM