Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added creating indexes for collection #300

Merged
merged 3 commits into from
Aug 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file.
## Unreleased
**List of changes that are finished but not yet released in any final version.**

- [PR-300](https://github.com/Cognifide/aet/pull/300) Added creating indexes for collection
- [PR-289](https://github.com/Cognifide/aet/pull/289) User now stays on the same tab while navigating between URLs
- [PR-271](https://github.com/Cognifide/aet/pull/271) Added possibility to override name parameter from the aet client
- [PR-268](https://github.com/Cognifide/aet/pull/268) Bobcat upgrade to version 1.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mongodb.DB;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import java.net.UnknownHostException;
import java.util.ArrayList;
Expand All @@ -33,6 +34,9 @@
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.bson.BsonDocument;
import org.bson.BsonInt32;
import org.bson.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -199,6 +203,15 @@ public MongoDatabase getDatabase(String dbName, Boolean autoCreate) {
} else if (allowAutoCreate && autoCreate) {
database = mongoClient.getDatabase(lowerCaseDbName);
database.createCollection(MetadataDAOMongoDBImpl.METADATA_COLLECTION_NAME);
MongoCollection<Document> collection = database
.getCollection(MetadataDAOMongoDBImpl.METADATA_COLLECTION_NAME);
collection.createIndex(new BsonDocument().append("version", new BsonInt32(-1)));
collection.createIndex(new BsonDocument()
.append("correlationId", new BsonInt32(1))
.append("version", new BsonInt32(-1)));
collection.createIndex(new BsonDocument()
.append("name", new BsonInt32(1))
.append("version", new BsonInt32(-1)));
}
return database;
}
Expand Down