当前位置: 首页>>代码示例>>C++>>正文


C++ Query::add方法代码示例

本文整理汇总了C++中Query::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Query::add方法的具体用法?C++ Query::add怎么用?C++ Query::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Test_Prefix_Fuzzy

void Test_Prefix_Fuzzy(QueryEvaluator * queryEvaluator) {
    set<unsigned> resultSet0, resultSet1, resultSet2;
    resultSet0.insert(1007);
    resultSet0.insert(1006);
    resultSet0.insert(1003);
    resultSet0.insert(1005);

    resultSet1.insert(1007);
    resultSet1.insert(1003);
    resultSet1.insert(1005);

    resultSet2.insert(1003);
    resultSet2.insert(1005);
    //resultSet2.insert(4);

    int resultCount = 10;
    // create a query
    Query *query = new Query(srch2is::SearchTypeTopKQuery);
    string keywords[3] = {
            "pionn","fllio","shiii"
    };

    cout << "\n***PREFIX FUZZY***\nQuery:";
    TermType type = TERM_TYPE_PREFIX;
    cout << keywords[0] << "\n";
    Term *term0 = FuzzyTerm::create(keywords[0], type, 1, 1, 2);
    query->add(term0);
    QueryResults *queryResults = new QueryResults(new QueryResultFactory(),
    		queryEvaluator, query);
    LogicalPlan * logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    resultCount = queryEvaluator->search(logicalPlan, queryResults);
    checkResults(queryResults, &resultSet0);

    cout << "\nAdding Term:";
    cout << keywords[1] << "\n";
    Term *term1 = FuzzyTerm::create(keywords[1], type, 1, 1, 2);
    query->add(term1);
    QueryResults *queryResults1 = new QueryResults(new QueryResultFactory(),
    		queryEvaluator, query);
    logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    resultCount = queryEvaluator->search(logicalPlan, queryResults1);
    checkResults(queryResults1, &resultSet1);

    cout << "\nAdding Term:";
    cout << keywords[2] << "\n";
    Term *term2 = FuzzyTerm::create(keywords[2], type, 1, 1, 2);
    query->add(term2);
    QueryResults *queryResults2 = new QueryResults(new QueryResultFactory(),
    		queryEvaluator, query);
    logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    resultCount = queryEvaluator->search(logicalPlan, queryResults2);
    checkResults(queryResults2, &resultSet2);

    delete query;
    delete queryResults;
    delete queryResults1;
    delete queryResults2;

}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:59,代码来源:QueryEvaluator_Test.cpp

示例2: E

Query* Parser::E() {
  Query* par = new Query(SIGN_OR);
  par->add(T());
  while (!token.compare("OR") || !token.compare("|")) {  // T OR E
    if (!token.compare("OR"))
      match("OR");
    else
      match("|");
    par->add(T());
  }
  if (par->size() == 1) {
    Query* ret = par->get(0);
    par->clear();
    delete par;
    return ret;
  }
  return par;
}
开发者ID:sleepsort,项目名称:se,代码行数:18,代码来源:parser.cpp

示例3: T

Query* Parser::T() {
  Query* par = new Query(SIGN_AND);
  par->add(S());
  while (!token.compare("AND") || !token.compare("&")) {  // S AND T
    if (!token.compare("AND"))
      match("AND");
    else
      match("&");
    par->add(S());
  }
  if (par->size() == 1) {
    Query* ret = par->get(0);
    par->clear();
    delete par;
    return ret;
  }
  return par;
}
开发者ID:sleepsort,项目名称:se,代码行数:18,代码来源:parser.cpp

示例4: fireSearch

void fireSearch(QueryEvaluator * queryEvaluator, vector<unsigned> filter, ATTRIBUTES_OP attrOp, unsigned k, const vector<string> &searchKeywords,
                unsigned numOfResults, const vector<string> &resultIds, const vector<vector<vector<unsigned> > > &resultAttributeBitmap)
{
    
    Query *query = new Query(srch2::instantsearch::SearchTypeTopKQuery);
    QueryResultFactory * resultFactory = new QueryResultFactory();
    QueryResults * queryResults = new QueryResults(resultFactory,queryEvaluator, query);

    for (unsigned i = 0; i < searchKeywords.size(); ++i)
    {
        TermType termType = TERM_TYPE_PREFIX;
        Term *term = ExactTerm::create(searchKeywords[i], termType, 1, 0.5);
        term->addAttributesToFilter(filter, attrOp);
        query->setPrefixMatchPenalty(0.95);
        query->add(term);
    }


    LogicalPlan * logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    queryEvaluator->search(logicalPlan , queryResults);
//    QueryEvaluatorRuntimeParametersContainer runTimeParameters;
//    QueryEvaluator * queryEvaluator = new QueryEvaluator(indexer,&runTimeParameters );
    cout << "record found :" << queryResults->getNumberOfResults() << endl;
    ASSERT(queryResults->getNumberOfResults() == numOfResults);

    vector<vector<unsigned> > matchedAttributeBitmap;
    for (unsigned i = 0; i< numOfResults; ++i)
    {
        ASSERT(queryResults->getRecordId(i) == resultIds[i]);
        queryResults->getMatchedAttributes(i, matchedAttributeBitmap);
        for(int j = 0; j< matchedAttributeBitmap.size(); j++)
        	for(int k = 0; k< matchedAttributeBitmap[j].size(); k++)
        		ASSERT(matchedAttributeBitmap[j][k] == resultAttributeBitmap[i][j][k]);
    }

    delete queryResults;
    delete query;
    delete resultFactory;

}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:40,代码来源:AttributedBasedSearch_Test.cpp

示例5: S

Query* Parser::S() {
  Query* ret;
  if (!token.compare("(")) {  // (E)
    match("(");
    ret = E();
    match(")");
  } else if (!token.compare("NOT") || !token.compare("!")) {  // NOT *
    if (!token.compare("NOT"))
      match("NOT");
    else
      match("!");

    ret = new Query(SIGN_NOT);
    if (!token.compare("(")) {
      match("(");
      ret->add(E());
      match(")");
    } else {
      ret->add(new Query(token));
      token = next();
    }
  } else if (!token.compare("\"")) {  // " P "
    match("\"");
    ret = new Query(SIGN_PHRSE);
    while (token.compare("\"")) {
      ret->add(new Query(token));
      token = next();
    }
    match("\"");
  } else if (!peek().compare("\\")) { // W \N W
    ret = new Query(SIGN_NEAR);
    ret->add(new Query(token));
    token = next();
    match("\\");
    ret->attr = token;
    ret->add(new Query(next()));
    token = next();
  } else {  // W
    size_t pos = token.find("*");  
    if (pos != string::npos ) {  // wildcard query
      if (token.find("*",pos+1) != string::npos) {
        token.erase(remove(token.begin()+pos+1, token.end(), '*'), token.end());
      }
      ret = new Query(SIGN_WILDCARD);
      ret->token = token;
    } else {  // normal single query
      ret = new Query(token);
    }
    token = next();
    if (!isoperator(token) && !isend()) {  // soft conjunction: A B
      Query* par = new Query(SIGN_OR);
      par->add(ret);
      while (!isoperator(token) && !isend()) {
        ret = new Query(token);
        ret->token = token;
        par->add(ret);
        token = next();
      }
      ret = par;
    }
  }
  return ret;
}
开发者ID:sleepsort,项目名称:se,代码行数:63,代码来源:parser.cpp

示例6: Test_Complete_Exact

void Test_Complete_Exact(QueryEvaluator * queryEvaluator) {
    set<unsigned> resultSet0, resultSet1, resultSet2;
    resultSet0.insert(1007);
    resultSet0.insert(1006);
    resultSet0.insert(1003);
    //resultSet0.insert(4);

    resultSet1.insert(1007);
    resultSet1.insert(1003);
    //resultSet1.insert(4);

    resultSet2.insert(1003);
    //resultSet2.insert(3);
    //resultSet2.insert(4);

    int resultCount = 10;
    // create a query
    Query *query = new Query(srch2is::SearchTypeTopKQuery);
    string keywords[3] = { "pink", "floyd", "shine"};

    cout << "\n***COMPLETE EXACT***\nQuery:";
    TermType termType = TERM_TYPE_COMPLETE;
    cout << keywords[0] << "\n";
    Term *term0 = ExactTerm::create(keywords[0], termType, 1, 1);
    query->add(term0);
    QueryResults *queryResults = new QueryResults(new QueryResultFactory(),
            queryEvaluator, query);

    LogicalPlan * logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    resultCount = queryEvaluator->search(logicalPlan, queryResults);
    ASSERT(checkResults(queryResults, &resultSet0) == true);
    printResults(queryResults);

    cout << "\nAdding Term:";
    cout << keywords[1] << "\n";
    Term *term1 = ExactTerm::create(keywords[1], termType, 1, 1);
    query->add(term1);
    QueryResults *queryResults1 = new QueryResults(new QueryResultFactory(),
            queryEvaluator, query);
    logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);

    resultCount = queryEvaluator->search(logicalPlan, queryResults1);
    checkResults(queryResults1, &resultSet1);
    printResults(queryResults1);

    cout << "\nAdding Term:";
    cout << keywords[2] << "\n";
    Term *term2 = ExactTerm::create(keywords[2], termType, 1, 1);
    query->add(term2);
    QueryResults *queryResults2 = new QueryResults(new QueryResultFactory(),
    		queryEvaluator, query);
    logicalPlan = prepareLogicalPlanForUnitTests(query , NULL, 0, 10, false, srch2::instantsearch::SearchTypeTopKQuery);
    resultCount = queryEvaluator->search(logicalPlan, queryResults2);
    checkResults(queryResults2, &resultSet2);
    printResults(queryResults2);

    delete query;
    delete queryResults;
    delete queryResults1;
    delete queryResults2;
}
开发者ID:Poorvak,项目名称:srch2-ngn,代码行数:61,代码来源:QueryEvaluator_Test.cpp


注:本文中的Query::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。