Skip to content

Instantly share code, notes, and snippets.

@Shellbye
Created March 30, 2017 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shellbye/2103b43be549e0b1aa03b56cfaa864dc to your computer and use it in GitHub Desktop.
Save Shellbye/2103b43be549e0b1aa03b56cfaa864dc to your computer and use it in GitHub Desktop.
sphinxsearch python mysql
import MySQLdb
conn = MySQLdb.connect(host="127.0.0.1", port=9306)
cursor = conn.cursor()
cursor.execute("select * from test1 where MATCH ('@content another')")
rows = cursor.fetchall()
for row in rows:
for i in range(len(row)):
print row[i]
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source src1
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass = password
sql_db = test
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
FROM documents
sql_attr_uint = group_id
sql_attr_timestamp = date_added
sql_query_info = SELECT * FROM documents WHERE id=$id
}
index test1
{
source = src1
path = /var/lib/sphinxsearch/data/test1
docinfo = extern
charset_type = sbcs
}
index testrt
{
type = rt
rt_mem_limit = 32M
path = /var/lib/sphinxsearch/data/testrt
charset_type = utf-8
rt_field = title
rt_field = content
rt_attr_uint = gid
}
indexer
{
mem_limit = 32M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
read_timeout = 5
max_children = 30
pid_file = /var/run/sphinxsearch/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = /var/lib/sphinxsearch/data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment