1

error: invalid operands to binary expression ('key_context > >' and 'bsoncxx::v_noabi::builder::stream::document') open_document << conditionI << close_document << ~~~~~~~~~~~~~ ^ ~~~~~~~~~~

    using bsoncxx::builder::stream::document;
    using bsoncxx::builder::stream::open_document;
    using bsoncxx::builder::stream::close_document;
    using bsoncxx::builder::stream::open_array;
    using bsoncxx::builder::stream::close_array;
    using bsoncxx::builder::stream::finalize;

    typedef mongocxx::cursor::iterator dociter;
    typedef bsoncxx::v_noabi::document::view docview;

    mongocxx::instance inst{};
    mongocxx::client conn{mongocxx::uri{"mongodb://10.9.0.1:27017"}};
    mongocxx::collection collection = conn["crawler"]["article"];

    mongocxx::options::find opts;
    document query, conditionI, conditionII, options;
    conditionI << "publishTime" << open_document << "$gte" << timedomain << close_document;
    conditionII << "lastread" << open_document << "$gte" << readdomain << close_document;
    options << "read" << 1 << "likes" << 1 << "body.title" << 1 << "body.content" << 1;
    opts.limit(100);
    opts.sort(options.view());

    query << "$or" << open_array <<
            open_document << conditionI << close_document <<
            open_document << conditionII << close_document <<
            close_array;

    mongocxx::cursor cursor = collection.find(conditionI.view(), opts);
Leo Zhao
  • 77
  • 1
  • 12
  • I believe you also posted this to the C++ driver JIRA project: https://jira.mongodb.org/browse/CXX-860. Please see the answer given there. – acm Mar 09 '16 at 18:12
  • Thanks, it works. Additionally, should I repost the answer here? – Leo Zhao Mar 10 '16 at 02:39

0 Answers0