1、准备:
在官网:http://www.coreseek.cn/下载稳定版本。
在csft-3.2.14/api/java下可以找到sphinxapi.jar放到项目下。
2、一段使用java连接searchd服务,检索数据的例子
public class CoreseekTest {
public static void main(String[] args) {
long start = new Date().getTime();
for (int i = 0; i < 1; i++) {
exec();
}
long end = new Date().getTime();
System.out.println("平均使用时间=" + (end - start) + " ms");
}
@SuppressWarnings("unchecked")
private static void exec() {
String host = "localhost";
int port = 9316;
int mode = SphinxClient.SPH_MATCH_ALL;
//创建链接
SphinxClient cl = new SphinxClient();
try {
//查询关键字
StringBuffer q = new StringBuffer();
q.append("避风