Java Code Examples for com.mongodb.client.model.Filters#exists()
The following examples show how to use
com.mongodb.client.model.Filters#exists() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoThingsSearchPersistence.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Override public Source<Metadata, NotUsed> sudoStreamMetadata(final EntityId lowerBound) { final Bson notDeletedFilter = Filters.exists(FIELD_DELETE_AT, false); final Bson filter = lowerBound.isDummy() ? notDeletedFilter : Filters.and(notDeletedFilter, Filters.gt(FIELD_ID, lowerBound.toString())); final Bson relevantFieldsProjection = Projections.include(FIELD_ID, FIELD_REVISION, FIELD_POLICY_ID, FIELD_POLICY_REVISION, FIELD_PATH_MODIFIED); final Bson sortById = Sorts.ascending(FIELD_ID); final Publisher<Document> publisher = collection.find(filter) .projection(relevantFieldsProjection) .sort(sortById); return Source.fromPublisher(publisher).map(MongoThingsSearchPersistence::readAsMetadata); }
Example 2
Source File: CreateBsonVisitor.java From ditto with Eclipse Public License 2.0 | 5 votes |
/** * Creates the Bson object used for querying. * * @param criteria the criteria to create Bson for. * @param authorizationSubjectIds subject ids with which to restrict visibility, or null to not restrict visibility. * @return the Bson object */ public static Bson apply(final Criteria criteria, List<String> authorizationSubjectIds) { checkNotNull(criteria, "criteria"); checkNotNull(authorizationSubjectIds, "authorizationSubjectIds"); final Bson baseFilter = criteria.accept(new CreateBsonVisitor(authorizationSubjectIds)); final Bson globalReadableFilter = AbstractFieldBsonCreator.getGlobalReadBson(authorizationSubjectIds); final Bson notDeletedFilter = Filters.exists(FIELD_DELETE_AT, false); // Put both per-attribute-filter and global-read filter in the query so that: // 1. Purely negated queries do not return results invisible to the authorization subjects, and // 2. MongoDB may choose to scan the global-read index when the key-value filter does not discriminate enough. return Filters.and(baseFilter, globalReadableFilter, notDeletedFilter); }
Example 3
Source File: GetExistsBsonVisitor.java From ditto with Eclipse Public License 2.0 | 4 votes |
@Override Bson visitRootLevelField(final String fieldName) { return Filters.exists(fieldName); }