Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
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();
}