Implement hard limits on search results + offset

This commit is contained in:
Ivan Skytte Jørgensen
2016-03-08 15:00:42 +01:00
parent 8215b07788
commit db05f04247
3 changed files with 37 additions and 0 deletions

3
Conf.h

@ -154,6 +154,9 @@ class Conf {
int32_t m_sendEmailTimeout;
int32_t m_pingSpacer;
int32_t m_maxDocsWanted; //maximum number of results in one go. Puts a limit on SearchInput::m_docsWanted
int32_t m_maxFirstResultNum; //maximum document offset / result-page. Puts a limit on SearchInput::m_firstResultNum
int64_t m_msg40_msg39_timeout; //timeout for entire get-docid-list phase, in milliseconds.
int64_t m_msg3a_msg39_network_overhead; //additional latency/overhead of sending reqeust+response over network.

@ -148,6 +148,15 @@ bool Msg40::getResults ( SearchInput *si ,
return true;
}
//enforce hard limits
if(m_si->m_docsWanted > g_conf.m_maxDocsWanted) {
log(LOG_DEBUG,"msg40: limiting docs-wanted from %d to %d", m_si->m_docsWanted, g_conf.m_maxDocsWanted);
m_si->m_docsWanted = g_conf.m_maxDocsWanted;
}
if(m_si->m_firstResultNum > g_conf.m_maxFirstResultNum) {
log(LOG_DEBUG,"msg40: limiting docs-offset from %d to %d", m_si->m_firstResultNum, g_conf.m_maxFirstResultNum);
m_si->m_firstResultNum = g_conf.m_maxFirstResultNum;
}
// how many docids do we need to get?
int32_t get = m_si->m_docsWanted + m_si->m_firstResultNum ;
// we get one extra for so we can set m_moreToFollow so we know

@ -8701,6 +8701,31 @@ void Parms::init ( ) {
m++;
m->m_title = "max results per page";
m->m_desc = "Maximum allowed number of results per page. Puts a limit to what user can request with CGI parameters";
m->m_cgi = "max_results_per_page";
m->m_off = offsetof(Conf,m_maxDocsWanted);
m->m_xml = "max_results_per_page";
m->m_type = TYPE_LONG;
m->m_page = PAGE_SEARCH;
m->m_obj = OBJ_CONF;
m->m_def = "100";
m->m_flags = 0;
m++;
m->m_title = "max results offset";
m->m_desc = "Maximum result offset. Puts a limit to what user can request with CGI parameters";
m->m_cgi = "max_results_offset";
m->m_off = offsetof(Conf,m_maxFirstResultNum);
m->m_xml = "max_results_offset";
m->m_type = TYPE_LONG;
m->m_page = PAGE_SEARCH;
m->m_obj = OBJ_CONF;
m->m_def = "200";
m->m_flags = 0;
m++;
m->m_title = "msg40->39 timeout";
m->m_desc = "Timeout for Msg40/Msg3a to collect candidate docids with Msg39. In milliseconds";
m->m_cgi = "msgfourty_msgthirtynine_timeout";