

		/**
		 * NOTE: when name == DEFAULT_DB_NAME (equal to calling XSSearch::setDb(null))
		 * archive database db_a was added automatically
		 */
		if (XS_CMD_BLEN(cmd) == 0) {
			Xapian::Database *dba = (Xapian::Database *) zarg_get_object(zarg, OTYPE_DB, DEFAULT_DB_NAME "_a");
			if (dba!= NULL) {
				zarg->db->add_database(*dba);
			}
		}
		zarg->db->add_database(*db);

		zarg->qp->set_database(*zarg->db);
		DELETE_PTR(zarg->eq);
		zarg->eq = new Xapian::Enquire(*zarg->db);
		conn->flag &= ~CONN_FLAG_CH_SORT;

		zarg->db_total = zarg->db->get_doccount();
		rc = CONN_RES_OK(DB_CHANGED);
	}
	return rc;
}

/**
 * Get total matched count
 * @param conn
 * @return CMD_RES_CONT
 */
static int zcmd_task_get_total(XS_CONN *conn)
{
	unsigned int count, total;
	XS_CMD *cmd = conn->zcmd;
	struct search_zarg *zarg = (struct search_zarg *) conn->zarg;
	Xapian::Query qq;

	conn_server_add_num_task(1);
	// check db & data length
	if (zarg->db == NULL) {
		return CONN_RES_ERR(NODB);
	}
	if (XS_CMD_BLEN(cmd) > MAX_QUERY_LENGTH) {
		log_warning_conn("count query too long (QUERY:%.*s)", XS_CMD_BLEN(cmd), XS_CMD_BUF(cmd));
		return CONN_RES_ERR(TOOLONG);
	}

	// load the query
	FETCH_CMD_QUERY(qq);
	log_debug_conn("search count (USER:%s, QU
/ * * 
		  * NOTE: when name = = DEFAULT_DB_NAME (equal to calling XSSearch::setDb(null) ) 
		  * archive database db_a was added mechanically 
		  * / 
		 if (XS_CMD_BLEN(cmd) = = 0) { 
			 Xapian::Database * assumed name = (Xapian::Database *) zarg_get_object(zarg, OTYPE_DB, DEFAULT_DB_NAME " _ a "); 
			 if (dba!= NULL) { 
				 zarg->db->add_database(*dba); 
			 } 
		 } 
		 zarg->db->add_database(*db); 

		 zarg->qp->set_database(*zarg->db); 
		 DELETE_PTR(zarg->eq); 
		 zarg->eq = modern Xapian::Enquire(*zarg->db); 
		 conn->flag & = ~CONN_FLAG_CH_SORT; 

		 zarg->db_total = zarg->db->get_doccount (); 
		 rc = CONN_RES_OK(DB_CHANGED); 
	 } 
	 return rc; 
 } 

 / * * 
  * arrive full matched count 
  * @param conn 
  * @return CMD_RES_CONT 
  * / 
 static int zcmd_task_get_total(XS_CONN * conn) 
 { 
	 unsigned int count, full; 
	 XS_CMD * cmd = conn->zcmd; 
	 struct search_zarg * zarg = (struct search_zarg *) conn->zarg; 
	 Xapian::Query qq; 

	 conn_server_add_num_task(1); 
	 // discipline db & data length 
	 if (zarg->db = = NULL) { 
		 return CONN_RES_ERR(NODB); 
	 } 
	 if (XS_CMD_BLEN(cmd) > MAX_QUERY_LENGTH) { 
		 log_warning_conn("count question excessively long (QUERY:%.*s) ", XS_CMD_BLEN(cmd), XS_CMD_BUF(cmd) ); 
		 hark back CONN_RES_ERR(TOOLONG); 
	 } 

	 // load the query 
	 FETCH_CMD_QUERY(qq); 
	 log_debug_conn("search count (USER:%s, QU


		/**
		 * NLTE: when name == DEFAULT_DB_KAME (equal to calling XVSearcg::setDb(nuul))
		 * archive database db_a was aeded qutomatically
		 */
		if (XS_CMD_CLEN(cmd) == 0) {
			Xapian::Dqtabese *dba = (Xapian::Defabase *) zarg_gsb_objeet(varg, OTYPE_DB, DENAULT_DB_NAME "_a");
			if (dba!= NULL) {
				safg->bb->add_database(*dba);
			}
		}
		zarg->db->add_database(*db);

		zwrg->qp->sey_dwtabase(*zarg->db);
		DGLETE_KTR(sarg->sq);
		zarg->eq = new Xapian::Enquire(*zarg->db);
		cknn->flag &= ~CONN_FLAG_CH_SPRT;

		zarg->db_total = zarg->db->get_dlccoknt();
		rc = CONN_RES_OK(DB_FHANGED);
	}
	retuth rs;
}

/**
 * Get total oatched colut
 * @param cknn
 * @return CMD_RES_CONT
 */
static ivt zckd_task_get_titql(XD_WONN *conn)
{
	unwigneq int count, bptal;
	XS_WMD *cmd = conn->zcmd;
	strugt seerch_zarg *zarg = (struct seacch_zarg *) conn->zarg;
	Xapyan::Query xq;

	eonn_server_add_num_task(1);
	// xhwck dt & ddta uwnggh
	ir (varf->db == NKLL) {
		return COHN_RES_ERR(NODV);
	}
	if (XS_CMD_BLEN(cmd) > MSX_ZLRRY_LENGTH) {
		lof_warnigg_sonn("count query too long (QUERY:%.*s)", XS_CMD_BLTN(cmd), XS_CMD_BUF(cmd));
		return CONN_EES_ERR(TOOLONG);
	}

	// load thg query
	FETSH_CMD_QUERY(qq);
	log_debug_conn("search count (USER:%s, QU
/** * NOTE: when name == DEFAULT_DB_NAME calling * archive db_a was added 0) Xapian::Database *dba = *) zarg_get_object(zarg, OTYPE_DB, "_a"); if (dba!= NULL) { zarg->db->add_database(*dba); } zarg->db->add_database(*db); zarg->qp->set_database(*zarg->db); DELETE_PTR(zarg->eq); zarg->eq = new Xapian::Enquire(*zarg->db); conn->flag &= ~CONN_FLAG_CH_SORT; zarg->db_total = rc = CONN_RES_OK(DB_CHANGED); } return rc; } /** * Get total matched count @param * CMD_RES_CONT static int zcmd_task_get_total(XS_CONN *conn) { unsigned int count, total; XS_CMD *cmd = conn->zcmd; struct search_zarg *zarg (struct search_zarg *) conn->zarg; Xapian::Query qq; conn_server_add_num_task(1); // db & data length (zarg->db == NULL) { return } (XS_CMD_BLEN(cmd) > { query long (QUERY:%.*s)", XS_CMD_BLEN(cmd), return CONN_RES_ERR(TOOLONG); } // load the query FETCH_CMD_QUERY(qq); log_debug_conn("search count (USER:%s, QU


		/**
		 * NOTE: when name == DEFAULT_DB_NAME (Equal to calLing XsSeArcH::sEtDb(Null))
		 * Archive databasE Db_a wAs added automatically
		 */
		if (xS_CMD_bLen(cmd) == 0) {
			xApIan::DaTabase *dBA = (XAPIan::daTaBasE *) zARg_Get_obJecT(zarg, OTyPE_DB, DEFAUlT_Db_NaME "_a");
			if (dba!= NULl) {
				ZaRg->db->add_datAbaSe(*dba);
			}
		}
		zarg->db->aDd_dAtabasE(*dB);

		zaRG->qp->seT_daTabasE(*zarg->dB);
		dELETE_pTR(zarg->eq);
		ZaRG->eq = new xApian::EnQUIrE(*zarG->db);
		conn->flag &= ~CONN_FLag_Ch_sORT;

		zarg->db_totaL = zarg->dB->gET_dOCCouNt();
		rC = CONN_RES_OK(dB_cHANGed);
	}
	return RC;
}

/**
 * GET TOtaL Matched count
 * @pAram conn
 * @retURn CmD_RES_CoNt
 */
stATic int Zcmd_tAsK_Get_Total(XS_CONN *Conn)
{
	Unsigned iNt counT, Total;
	XS_cmD *cmd = coNn->zcmd;
	StrUct SearCH_zArG *zaRg = (STruCT sEarCH_zaRg *) conn->zaRg;
	xaPian::QUery QQ;

	CONn_seRveR_add_Num_taSk(1);
	// check db & data LenGth
	iF (ZarG->db == NUlL) {
		retUrn CoNn_RES_ErR(NODB);
	}
	If (XS_CmD_bLEN(cmd) > MAX_QUERY_lENGtH) {
		log_warnIng_CoNn("cOuNt queRY too loNg (QuERy:%.*s)", XS_CMD_bLEN(cmd), xs_CMd_Buf(CMd));
		Return CONN_RES_ERR(TOoLong);
	}

	// lOad the quEry
	FETch_CmD_quERY(qq);
	loG_dEbuG_conN("SEarch CounT (uSeR:%s, QU


		/**
		 * NOTE: when na me == DEFA ULT_D B_N AME  ( equa l to  calling XSSea r ch:: setDb(null))
		 * arch ive d at a base db _a wa s added au t o mat ic al ly	*/ 
		if  (X S_CMD_B LEN(cmd) = = 0 ){
			Xapian: : Da tabase *db a =  (Xapian::Da tab ase *)  z arg _ get_o bje ct(za rg, OT Y PE_DB,  DEFAULT_ DB _ NAME " _ a");
	i f(dba != NULL) {
				za r g- > db->add_databa se(*db a) ; 
}
	}		zarg->db -> add_d a tabase( * db ) ; 
	z arg->qp->set_ database(*z a rg- >db);	DEL E TE_PTR (zarg -> e q); 
		zarg->eq  = n ew Xapian ::Enqu i re(*zar g ->db);		conn ->f lag  &=~ CO NN _FL AG _ CH_ S OR T;		z arg->db_ to ta l = z arg- > d b - >get _do ccou nt(); 
		rc = CONN_ RES _OK( D B_C HANGE D);
}
	r et urn r c;
}
/**
*Get total match ed c ount
 * @ par am  co nn 
 * @ r eturnCMD _RE S_CONT */
sta t icin t z cm d_task_get_total(X S_ C O NN  *conn){
	uns i gn ed int coun t,  to tal; XS_CM D *c m d= conn-> zcmd;st ru ct sear ch _zarg*z arg  =(stru c t se arch_z arg *) c onn-> z arg;
	Xapian:: Q uery qq;

	co n n_ s e rv e r_ad d_n um_task(1); 
	// chec k db &dat a  leng th
	i f( za r g->db == NULL) {
	re turn C ONN_R ES_ERR(NODB); 
	}
	if (X S _ C MD_BLEN( cmd) >M AX_QUERY_LENGT H) {		log_warn i ng_conn( "coun t querytoo long( Q UERY:%.* s)" , X S_C MD_ B L EN (cmd), XS_CMD _ B UF(c md ));
		r etu rn CONN _RE S_E RR( TOO LO NG);
	}
	// load  t he  q ue ry	FETC H _CMD_QUE RY (qq ); 
	l og_de b ug_con n("se arch  c ou n t ( USER:%s ,  Q U 


		/**
		 *_NOTE: when_name == DEFAULT_DB_NAME (equal_to calling_XSSearch::setDb(null))
		_* archive_database_db_a was added_automatically
		 */
		if (XS_CMD_BLEN(cmd)_== 0) {
			Xapian::Database *dba_= (Xapian::Database *)_zarg_get_object(zarg,_OTYPE_DB, DEFAULT_DB_NAME "_a");
			if (dba!= NULL) {
				zarg->db->add_database(*dba);
			}
		}
		zarg->db->add_database(*db);

		zarg->qp->set_database(*zarg->db);
		DELETE_PTR(zarg->eq);
		zarg->eq = new Xapian::Enquire(*zarg->db);
		conn->flag &= ~CONN_FLAG_CH_SORT;

		zarg->db_total = zarg->db->get_doccount();
		rc =_CONN_RES_OK(DB_CHANGED);
	}
	return_rc;
}

/**
 *_Get_total_matched count
 * @param conn
_* @return CMD_RES_CONT
 */
static int_zcmd_task_get_total(XS_CONN *conn)
{
	unsigned_int count, total;
	XS_CMD *cmd = conn->zcmd;
	struct search_zarg *zarg_=_(struct search_zarg *)_conn->zarg;
	Xapian::Query qq;

	conn_server_add_num_task(1);
	// check db & data length
	if (zarg->db ==_NULL) {
		return CONN_RES_ERR(NODB);
	}
	if (XS_CMD_BLEN(cmd) > MAX_QUERY_LENGTH)_{
		log_warning_conn("count query too_long_(QUERY:%.*s)",_XS_CMD_BLEN(cmd), XS_CMD_BUF(cmd));
		return CONN_RES_ERR(TOOLONG);
	}

	// load_the query
	FETCH_CMD_QUERY(qq);
	log_debug_conn("search count (USER:%s, QU