Revert "fix json search results formatting."

This reverts commit 7879537ab6.
This commit is contained in:
Matt Wells 2015-03-12 15:42:20 -07:00
parent 7879537ab6
commit 48435c55b1
2 changed files with 12 additions and 20 deletions

View File

@ -543,6 +543,10 @@ bool sendPageResults ( TcpSocket *s , HttpRequest *hr ) {
// save this count so we know if TcpServer.cpp calls destroySocket(s)
st->m_numDestroys = s->m_numDestroys;
// you have to say "&header=1" to get back the header for json now.
// later on maybe it will default to on.
st->m_header = hr->getLong("header",0);
// . parse it up
// . this returns false and sets g_errno and, maybe, g_msg on error
SearchInput *si = &st->m_si;
@ -572,17 +576,6 @@ bool sendPageResults ( TcpSocket *s , HttpRequest *hr ) {
if ( format == FORMAT_JSON && ! cr->m_isCustomCrawl )
st->m_header = 1;
// global-index is not a custom crawl but we should use "objects"
bool isDiffbot = cr->m_isCustomCrawl;
if ( strcmp(cr->m_coll,"GLOBAL-INDEX") == 0 ) isDiffbot = true;
st->m_isDiffbot = isDiffbot;
if ( st->m_isDiffbot ) st->m_header = 0;
// you have to say "&header=1" to get back the header for json now.
// later on maybe it will default to on.
st->m_header = hr->getLong("header",st->m_header);
// take this out here as well!
// limit here
// int32_t maxpp = cr->m_maxSearchResultsPerQuery ;
@ -1742,14 +1735,11 @@ bool printLeftNavColumn ( SafeBuf &sb, State0 *st ) {
//int32_t numCols = 5;
//int32_t perRow = numGigabits / numCols;
if ( ! st->m_header )
numGigabits = 0;
if ( numGigabits && format == FORMAT_XML )
sb.safePrintf("\t<gigabits>\n");
if ( numGigabits && format == FORMAT_JSON )
sb.safePrintf("\"gigabits\":{\n");
sb.safePrintf("\"gigabits\":{\n");
if ( numGigabits && format == FORMAT_HTML )
@ -2645,17 +2635,20 @@ bool printSearchResultsHeader ( State0 *st ) {
printLeftNavColumn ( *sb,st );
}
// global-index is not a custom crawl but we should use "objects"
bool isDiffbot = cr->m_isCustomCrawl;
if ( strcmp(cr->m_coll,"GLOBAL-INDEX") == 0 ) isDiffbot = true;
// for diffbot collections only...
if ( st->m_header &&
si->m_format == FORMAT_JSON &&
st->m_isDiffbot ) {
isDiffbot ) {
sb->safePrintf("\"objects\":[\n");
return true;
}
if ( st->m_header &&
si->m_format == FORMAT_JSON &&
! st->m_isDiffbot ) {
if ( si->m_format == FORMAT_JSON &&
! cr->m_isCustomCrawl ) {
sb->safePrintf("\"results\":[\n");
return true;
}

View File

@ -25,7 +25,6 @@ public:
// m_socket->m_numDestroys
int32_t m_numDestroys;
bool m_header;
bool m_isDiffbot;
collnum_t m_collnum;
//Query m_q;