コード例 #1
0
ファイル: fts_spec.cpp プロジェクト: GitSullied/mongo
Status FTSSpec::getIndexPrefix( const BSONObj& query, BSONObj* out ) const {
    if ( numExtraBefore() == 0 ) {
        *out = BSONObj();
        return Status::OK();
    }

    BSONObjBuilder b;
    for ( unsigned i = 0; i < numExtraBefore(); i++ ) {
        BSONElement e = query.getFieldDotted(extraBefore(i));
        if ( e.eoo() )
            return Status( ErrorCodes::BadValue,
                           str::stream()
                           << "need have an equality filter on: "
                           << extraBefore(i) );

        if ( e.isABSONObj() && e.Obj().firstElement().getGtLtOp( -1 ) != -1 )
            return Status( ErrorCodes::BadValue,
                           str::stream()
                           << "need have an equality filter on: "
                           << extraBefore(i) );

        b.append( e );
    }
    *out = b.obj();
    return Status::OK();
}
コード例 #2
0
ファイル: fts_spec.cpp プロジェクト: acmorrow/mongo
Status FTSSpec::getIndexPrefix(const BSONObj& query, BSONObj* out) const {
    if (numExtraBefore() == 0) {
        *out = BSONObj();
        return Status::OK();
    }

    BSONObjBuilder b;
    for (unsigned i = 0; i < numExtraBefore(); i++) {
        BSONElement e = dps::extractElementAtPath(query, extraBefore(i));
        if (e.eoo())
            return Status(ErrorCodes::BadValue,
                          str::stream() << "need have an equality filter on: " << extraBefore(i));

        if (e.isABSONObj() &&
            MatchExpressionParser::parsePathAcceptingKeyword(e.Obj().firstElement()))
            return Status(ErrorCodes::BadValue,
                          str::stream() << "need have an equality filter on: " << extraBefore(i));

        b.append(e);
    }
    *out = b.obj();
    return Status::OK();
}