org.springframework.data.mongodb.core.MongoTemplate.indexOps()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.indexOps()方法的一些代码示例,展示了MongoTemplate.indexOps()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.indexOps()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:indexOps

MongoTemplate.indexOps介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

@Override
public void afterPropertiesSet() throws Exception {
  if (this.applicationContext != null) {
    this.converter.setApplicationContext(this.applicationContext);
  }
  this.converter.afterPropertiesSet();
  IndexOperations indexOperations = this.template.indexOps(this.collectionName);
  indexOperations.ensureIndex(new Index(GROUP_ID_KEY, Sort.Direction.ASC)
      .on(GROUP_UPDATE_TIMESTAMP_KEY, Sort.Direction.DESC)
      .on(SEQUENCE, Sort.Direction.DESC));
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public void afterPropertiesSet() throws Exception {
  super.afterPropertiesSet();
  this.mongoTemplate.indexOps(this.collectionName)
      .ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
          .on(MessageDocumentFields.PRIORITY, Sort.Direction.DESC)
          .on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.ASC)
          .on(MessageDocumentFields.SEQUENCE, Sort.Direction.ASC));
}

代码示例来源:origin: spring-projects/spring-integration

@Override
public void afterPropertiesSet() throws Exception {
  if (this.mongoTemplate == null) {
    if (this.mappingMongoConverter == null) {
      this.mappingMongoConverter = new MappingMongoConverter(new DefaultDbRefResolver(this.mongoDbFactory),
          new MongoMappingContext());
      this.mappingMongoConverter.setApplicationContext(this.applicationContext);
      List<Object> customConverters = new ArrayList<Object>();
      customConverters.add(new MessageToBinaryConverter());
      customConverters.add(new BinaryToMessageConverter());
      this.mappingMongoConverter.setCustomConversions(new MongoCustomConversions(customConverters));
      this.mappingMongoConverter.afterPropertiesSet();
    }
    this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mappingMongoConverter);
  }
  this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.applicationContext);
  IndexOperations indexOperations = this.mongoTemplate.indexOps(this.collectionName);
  indexOperations.ensureIndex(new Index(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC));
  indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
      .on(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC)
      .unique());
  indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
      .on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.DESC)
      .on(MessageDocumentFields.SEQUENCE, Sort.Direction.DESC));
}

代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl

private boolean indexNotExists(final String name) {
  List<IndexInfo> indexes = mongoTemplate.indexOps(collectionName).getIndexInfo();
  for (IndexInfo indexInfo : indexes) {
    if (name.equals(indexInfo.getName())) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: pl.edu.icm.crpd/crpd-persistence

@PostConstruct
public void ensureIndexes() throws Exception {
  mongoTemplate().indexOps(GRID_FS_THESIS_CONTENT_BUCKET +".files").ensureIndex(new Index("metadata.thesisMetadataId", Direction.ASC));
  mongoTemplate().indexOps(DataClient.class).ensureIndex(new Index().unique().on("name", Direction.ASC));
  mongoTemplate().indexOps(InstitutionalServer.class).ensureIndex(new Index().unique().on("institutionId", Direction.ASC));
}

代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl

private void upgradeIndexes() {
  if (indexNotExists(CONTENT_HASH_INDEX)) {
    mongoTemplate.indexOps(collectionName).ensureIndex(new Index().on("contentHash", Direction.ASC).named(CONTENT_HASH_INDEX));
  }
  if (indexNotExists(FLOW_NAME_INDEX)) {
    mongoTemplate.indexOps(collectionName).ensureIndex(new Index().on("flowName", Direction.ASC).named(FLOW_NAME_INDEX));
  }
}

代码示例来源:origin: Loki-Afro/multi-tenant-spring-mongodb

private void checkForAndCreateIndexes(final MongoPersistentEntityIndexResolver indexResolver, final MongoPersistentEntity<?> entity) {
//        make sure its a root document
    if (entity.findAnnotation(Document.class) != null) {
      for (IndexDefinitionHolder indexDefinitionHolder : indexResolver.resolveIndexForClass(entity.getType())) {
//                work because of javas reentered lock feature
        this.mongoTemplate.indexOps(entity.getType()).ensureIndex(indexDefinitionHolder);
      }
    }
  }
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
public void afterPropertiesSet() throws Exception {
  super.afterPropertiesSet();
  this.mongoTemplate.indexOps(this.collectionName)
      .ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
          .on(MessageDocumentFields.PRIORITY, Sort.Direction.DESC)
          .on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.ASC)
          .on(MessageDocumentFields.SEQUENCE, Sort.Direction.ASC));
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
public void afterPropertiesSet() throws Exception {
  if (this.applicationContext != null) {
    this.converter.setApplicationContext(this.applicationContext);
  }
  this.converter.afterPropertiesSet();
  IndexOperations indexOperations = this.template.indexOps(this.collectionName);
  indexOperations.ensureIndex(new Index(GROUP_ID_KEY, Sort.Direction.ASC)
      .on(GROUP_UPDATE_TIMESTAMP_KEY, Sort.Direction.DESC)
      .on(SEQUENCE, Sort.Direction.DESC));
}

代码示例来源:origin: org.springframework.integration/spring-integration-mongodb

@Override
public void afterPropertiesSet() throws Exception {
  if (this.mongoTemplate == null) {
    if (this.mappingMongoConverter == null) {
      this.mappingMongoConverter = new MappingMongoConverter(new DefaultDbRefResolver(this.mongoDbFactory),
          new MongoMappingContext());
      this.mappingMongoConverter.setApplicationContext(this.applicationContext);
      List<Object> customConverters = new ArrayList<Object>();
      customConverters.add(new MessageToBinaryConverter());
      customConverters.add(new BinaryToMessageConverter());
      this.mappingMongoConverter.setCustomConversions(new MongoCustomConversions(customConverters));
      this.mappingMongoConverter.afterPropertiesSet();
    }
    this.mongoTemplate = new MongoTemplate(this.mongoDbFactory, this.mappingMongoConverter);
  }
  this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.applicationContext);
  IndexOperations indexOperations = this.mongoTemplate.indexOps(this.collectionName);
  indexOperations.ensureIndex(new Index(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC));
  indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
      .on(MessageDocumentFields.MESSAGE_ID, Sort.Direction.ASC)
      .unique());
  indexOperations.ensureIndex(new Index(MessageDocumentFields.GROUP_ID, Sort.Direction.ASC)
      .on(MessageDocumentFields.LAST_MODIFIED_TIME, Sort.Direction.DESC)
      .on(MessageDocumentFields.SEQUENCE, Sort.Direction.DESC));
}

相关文章