我总共有 720 个狮身人面像索引,大小为 1.21 GB。这里附有一项服务的所有索引。它需要 800MB 的 RAM。我使用 sql_attr_str2ordinal 来存储字符串,所以 RAM 减少了,现在只需要 17MB。但这里的问题是搜索结果给出 0 个匹配项。使用 sphinx 索引中的 java api 应用搜索。conf文件和java代码如下:
searchd{
listen = 516
log = D:\programs\spinx\spinxexperiment\project\log\searchd.log
query_log = D:\programs\spinx\spinxexperiment\project\log\query.log
read_timeout = 5
max_children = 30
pid_file = D:\programs\spinx\spinxexperiment\project\log\searchd.pid
max_matches = 1000
seamless_rotate = 0
preopen_indexes = 0
unlink_old = 1
ondisk_dict_default = 1
mva_updates_pool = 1M
workers = threads # for RT to work}
source webusagedatagroup20120301{
type = pgsql
sql_host = 127.0.0.1
sql_user = postgres
sql_pass =
sql_db = iviewdb
sql_port = 5432
sql_query = SELECT id,username as username_ord,domain as domain_ord,application,hits,bytes from webusagedata1
sql_attr_str2ordinal = username_ord
sql_attr_str2ordinal = domain_ord
sql_attr_str2ordinal = application
sql_attr_bigint = hits
sql_attr_bigint = bytes}
index webusagedatagroup20120301{
source = webusagedatagroup20120301
path = D:\programs\spinx\spinxexperiment\project\data\20120301\group\webusagedatagroup20120301
preopen = 0
docinfo = inline
ondisk_dict = 1
charset_type = sbcs
rt_field = username
rt_field = domain
rt_field = application
rt_attr_bigint = hits
rt_attr_bigint = bytes}
代码:
client = new SphinxClient("127.0.0.1",516);
client.SetMatchMode(SphinxClient.SPH_MATCH_PHRASE);
query=prepareQuery();
client.SetLimits(0, 20);
client.SetMaxQueryTime(0);
client.SetConnectTimeout(60000);
client.SetSelect("*, SUM(bytes) as bytes_total");
client.SetGroupBy("application", SphinxClient.SPH_GROUPBY_ATTR,"username asc");
SphinxResult res = client.Query("divyesh.modi", "webusagedatagroup20120130");