本文整理汇总了C++中FTSQuery::debugString方法的典型用法代码示例。如果您正苦于以下问题:C++ FTSQuery::debugString方法的具体用法?C++ FTSQuery::debugString怎么用?C++ FTSQuery::debugString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FTSQuery
的用法示例。
在下文中一共展示了FTSQuery::debugString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST( FTSQuery, Phrase1 ) {
FTSQuery q;
ASSERT( q.parse( "doing a \"phrase test\" for fun", "english" ).isOK() );
ASSERT_EQUALS( 3U, q.getTerms().size() );
ASSERT_EQUALS( 0U, q.getNegatedTerms().size() );
ASSERT_EQUALS( 1U, q.getPhr().size() );
ASSERT_EQUALS( 0U, q.getNegatedPhr().size() );
ASSERT_EQUALS( "phrase test", q.getPhr()[0] );
ASSERT_EQUALS( "fun|phrase|test||||phrase test||", q.debugString() );
}
示例2: ASSERT
TEST(FTSQuery, Phrase1) {
FTSQuery q;
ASSERT(
q.parse("doing a \"phrase test\" for fun", "english", false, TEXT_INDEX_VERSION_2).isOK());
ASSERT_EQUALS(3U, q.getPositiveTerms().size());
ASSERT_EQUALS(0U, q.getNegatedTerms().size());
ASSERT_EQUALS(1U, q.getPositivePhr().size());
ASSERT_EQUALS(0U, q.getNegatedPhr().size());
ASSERT_TRUE(q.getTermsForBounds() == q.getPositiveTerms());
ASSERT_EQUALS("phrase test", q.getPositivePhr()[0]);
ASSERT_EQUALS("fun|phrase|test||||phrase test||", q.debugString());
}
示例3: _run
/*
* Runs the command object cmdobj on the db with name dbname and puts result in result.
* @param dbname, name of db
* @param cmdobj, object that contains entire command
* @param options
* @param errmsg, reference to error message
* @param result, reference to builder for result
* @param fromRepl
* @return true if successful, false otherwise
*/
bool FTSCommand::_run(const string& dbname,
BSONObj& cmdObj,
int cmdOptions,
const string& ns,
const string& searchString,
string language, // "" for not-set
int limit,
BSONObj& filter,
BSONObj& projection,
string& errmsg,
BSONObjBuilder& result ) {
Timer comm;
scoped_ptr<Projection> pr;
if ( !projection.isEmpty() ) {
pr.reset( new Projection() );
pr->init( projection );
}
// priority queue for results
Results results;
Database* db = cc().database();
Collection* collection = db->getCollection( ns );
if ( !collection ) {
errmsg = "can't find ns";
return false;
}
vector<int> idxMatches;
collection->details()->findIndexByType( INDEX_NAME, idxMatches );
if ( idxMatches.size() == 0 ) {
errmsg = str::stream() << "no text index for: " << ns;
return false;
}
if ( idxMatches.size() > 1 ) {
errmsg = str::stream() << "too many text indexes for: " << ns;
return false;
}
BSONObj indexPrefix;
IndexDescriptor* descriptor = collection->getIndexCatalog()->getDescriptor(idxMatches[0]);
auto_ptr<FTSAccessMethod> fam(new FTSAccessMethod(descriptor));
if ( language == "" ) {
language = fam->getSpec().defaultLanguage().str();
}
Status s = fam->getSpec().getIndexPrefix( filter, &indexPrefix );
if ( !s.isOK() ) {
errmsg = s.toString();
return false;
}
FTSQuery query;
if ( !query.parse( searchString, language ).isOK() ) {
errmsg = "can't parse search";
return false;
}
result.append( "queryDebugString", query.debugString() );
result.append( "language", language );
FTSSearch search(descriptor, fam->getSpec(), indexPrefix, query, filter );
search.go( &results, limit );
// grab underlying container inside priority queue
vector<ScoredLocation> r( results.dangerous() );
// sort results by score (not always in correct order, especially w.r.t. multiterm)
sort( r.begin(), r.end() );
// build the results bson array shown to user
BSONArrayBuilder a( result.subarrayStart( "results" ) );
int tempSize = 1024 * 1024; // leave a mb for other things
long long numReturned = 0;
for ( unsigned n = 0; n < r.size(); n++ ) {
BSONObj obj = BSONObj::make(r[n].rec);
BSONObj toSendBack = obj;
if ( pr ) {
toSendBack = pr->transform(obj);
}
if ( ( tempSize + toSendBack.objsize() ) >= BSONObjMaxUserSize ) {
break;
}
//.........这里部分代码省略.........