简体   繁体   中英

Converting MySQL to a Sphinx Search Platform

Currently working on an in-house search engine for over 12 GB / month of MySQL data.

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.

The issue I'm having is the format of the practice number is STR:NUM:NUM.

Sphinx Search says that is an invalid or Null ID format and a ID needs to be just NUM.

An example of our current ID's is YV0091 which will have corresponding data in both tables.

The ID's cannot be changed or manipulated due to them being a standardised ID in our industry.

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. 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)

Alas sphinx doesnt have a 'autoincrement' style way of allocating the id, so need to contrive it yourself. For example using a mysql user-variable...

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 . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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