因为项目需要用到分页功能,所以需要用到SetLimits函数,结果就出现了Error: searchd error: offset out of bounds (offset=9500, max_matches=1000)
于是找原因,发现配置文件中有max_matches这个选项,于是将它改为10000,可是依然出现Error: searchd error: offset out of bounds (offset=9500, max_matches=1000)错误,真是莫名其妙的错误,仔细看了SetLimits的函数说明以及SphinxClient.java,才知道使用SetLimits这个函数时,如果没有提供max_matches这个参数的值,则max_matches默认为1000,而9500超过了1000,所以溢出了。
source srcmain : base{ sql_query_pre = SET NAMES utf8 sql_query_pre = SET SESSION query_cache_type=OFF sql_query_pre = UPDATE sphinx_helper SET main_tmp_maxts=NOW() WHERE appid='blog_search'; sql_query = \ SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_modified) AS post_modified FROM wp_posts WHERE\ post_status='publish'AND post_modified < (SELECT main_tmp_maxts FROM sphinx_helper WHERE appid='blog_search'); sql_query_post_index = UPDATE sphinx_helper SET main_maxts=main_tmp_maxts WHERE appid='blog_search'; sql_query_post_index = DELETE FROM sphinxklist WHERE ts < (SELECT main_maxts FROM sphinx_helper WHERE appid='blog_search'); sql_attr_timestamp = post_modified sql_field_string = post_title }
可以看到,相对于之前的配置,这里只添加了一行
1
sql_query_post_index = DELETEFROM sphinxklist WHERE ts < (SELECT main_maxts FROM sphinx_helper WHERE appid='blog_search');
添加这行是为了防止之前运行引擎时留下的id再次被使用。 之后修改临时索引:
1 2 3 4 5 6 7 8 9 10 11 12
source srcdelta_temp : srcmain { sql_query_pre = SET NAMES utf8 sql_query_pre = SET SESSION query_cache_type=OFF sql_query_pre = SET @maxtsdelta:=NOW(); sql_query_pre = UPDATE sphinx_helper SET delta_tmp_maxts=@maxtsdelta WHERE appid='blog_search'; sql_query = SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_modified) AS post_modified FROM wp_posts WHERE \ post_status='publish'AND post_modified >= (SELECT main_maxts FROM sphinx_helper WHERE appid='blog_search')\ AND post_modified < @maxtsdelta; sql_query_killlist = SELECT ID FROM wp_posts WHERE post_modified >= (SELECT main_maxts FROM sphinx_helper WHERE \ appid='blog_search') AND post_modified < @maxtsdelta UNION SELECT id FROM sphinxklist; sql_query_post_index = UPDATE sphinx_helper SET delta_maxts=delta_tmp_maxts WHERE appid='blog_search'; }