org.springframework.data.mongodb.core.index.Index Java Examples

The following examples show how to use org.springframework.data.mongodb.core.index.Index. 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: AgentIndexInitializer.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void createIndexOnName() {
    mongoOps.indexOps(Agent.class)
        .ensureIndex(new Index().on("name", Direction.ASC).unique());
}
 
Example #2
Source File: AgentIndexInitializer.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void createIndexOnName() {
    mongoOps.indexOps(Agent.class)
        .ensureIndex(new Index().on("name", Direction.ASC).unique());
}
 
Example #3
Source File: MongoTemplateQueryLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenUserExistsWithIndexAddedFromCode_whenCheckingIndex_thenIndexIsExisted() {
    final User user = new User();
    user.setName("Brendan");
    mongoTemplate.indexOps(User.class).ensureIndex(new Index().on("name", Direction.ASC));
    mongoTemplate.insert(user);

    List<IndexInfo> indexInfos = mongoTemplate.indexOps("user").getIndexInfo();

    assertThat(indexInfos.size(), is(2));
}
 
Example #4
Source File: MongoProcessor.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private void clearAndIndexCollection(String profiledCollectionName) {
    Query query = new Query();
    da.mongoTemplate.remove(query, profiledCollectionName);

    List<String> indexes = getIndexes();
    for(int i = 0; i < indexes.size(); i++) {
        da.mongoTemplate.indexOps(profiledCollectionName).ensureIndex(new Index().on(indexes.get(i), Order.ASCENDING)); 
    }
}
 
Example #5
Source File: MongoProcessor.java    From secure-data-service with Apache License 2.0 5 votes vote down vote up
private void setup(String profiledCollectionName) {
    // setup
    da.mongoTemplate.dropCollection(profiledCollectionName);
    da.mongoTemplate.createCollection(profiledCollectionName);

       List<String> indexes = getIndexes();
       for(int i = 0; i < indexes.size(); i++) {
           da.mongoTemplate.indexOps(profiledCollectionName).ensureIndex(new Index().on(indexes.get(i), Order.ASCENDING)); 
       }
}
 
Example #6
Source File: AgentIndexInitializer.java    From flow-platform-x with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void createIndexOnToken() {
    mongoOps.indexOps(Agent.class)
        .ensureIndex(new Index().on("token", Direction.ASC).unique());
}
 
Example #7
Source File: AgentIndexInitializer.java    From flow-platform-x with Apache License 2.0 4 votes vote down vote up
@PostConstruct
public void createIndexOnToken() {
    mongoOps.indexOps(Agent.class)
        .ensureIndex(new Index().on("token", Direction.ASC).unique());
}