returnnil,errors.New("SQLSearcher only supports MySQL at this time")
}
return&SQLSearcher{
queryReplies:acc.RawPrepare("SELECT tid FROM replies WHERE MATCH(content) AGAINST (? IN BOOLEAN MODE)"),
queryTopics:acc.RawPrepare("SELECT tid FROM topics WHERE MATCH(title) AGAINST (? IN BOOLEAN MODE) OR MATCH(content) AGAINST (? IN BOOLEAN MODE)"),
queryRepliesZone:acc.RawPrepare("SELECT tid FROM replies WHERE MATCH(content) AGAINST (? IN BOOLEAN MODE) AND tid=?"),
queryTopicsZone:acc.RawPrepare("SELECT tid FROM topics WHERE (MATCH(title) AGAINST (? IN BOOLEAN MODE) OR MATCH(content) AGAINST (? IN BOOLEAN MODE)) AND parentID=?"),
//queryZone: acc.RawPrepare("SELECT topics.tid FROM topics INNER JOIN replies ON topics.tid = replies.tid WHERE (topics.title=? OR (MATCH(topics.title) AGAINST (? IN BOOLEAN MODE) OR MATCH(topics.content) AGAINST (? IN BOOLEAN MODE) OR MATCH(replies.content) AGAINST (? IN BOOLEAN MODE)) OR topics.content=? OR replies.content=?) AND topics.parentID=?"),
fuzzyZone:acc.RawPrepare("SELECT topics.tid FROM topics INNER JOIN replies ON topics.tid = replies.tid WHERE (topics.title LIKE ? OR topics.content LIKE ? OR replies.content LIKE ?) AND topics.parentID=?"),
//err = run(s.queryZone.Query(q, q, q, q, q,q, zones[0]))
err=run(s.queryRepliesZone.Query(q,zones[0]))
iferr!=nil{
returnnil,err
}
err=run(s.queryTopicsZone.Query(q,q,zones[0]))
}else{
varzListstring
for_,zone:=rangezones{
zList+=strconv.Itoa(zone)+","
}
zList=zList[:len(zList)-1]
acc:=qgen.NewAcc()
/*stmt:=acc.RawPrepare("SELECT topics.tid FROM topics INNER JOIN replies ON topics.tid = replies.tid WHERE (MATCH(topics.title) AGAINST (? IN BOOLEAN MODE) OR MATCH(topics.content) AGAINST (? IN BOOLEAN MODE) OR MATCH(replies.content) AGAINST (? IN BOOLEAN MODE) OR topics.title=? OR topics.content=? OR replies.content=?) AND topics.parentID IN("+zList+")")
iferr=acc.FirstError();err!=nil{
returnnil,err
}*/
// TODO: Cache common IN counts
stmt:=acc.RawPrepare("SELECT tid FROM topics WHERE (MATCH(topics.title) AGAINST (? IN BOOLEAN MODE) OR MATCH(topics.content) AGAINST (? IN BOOLEAN MODE)) AND parentID IN("+zList+")")
iferr=acc.FirstError();err!=nil{
returnnil,err
}
err=run(stmt.Query(q,q))
iferr!=nil{
returnnil,err
}
stmt=acc.RawPrepare("SELECT tid FROM replies WHERE MATCH(replies.content) AGAINST (? IN BOOLEAN MODE) AND tid IN("+zList+")")