use of org.springframework.data.mongodb.core.index.TextIndexDefinition.TextIndexDefinitionBuilder in project ocvn by devgateway.
the class MongoTemplateConfiguration method createPostImportStructures.
public void createPostImportStructures() {
createCorruptionFlagsIndexes();
// initialize some extra indexes
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("ocid", Direction.ASC).unique());
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethodRationale", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.status", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.status", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.suppliers._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.date", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.publishedDate", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("awards.value.amount", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.value.amount", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.contrMethod._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.numberOfTenderers", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.cancellationRationale", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.submissionMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.publicationMethod", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE, Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_END_DATE, Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.classification._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.budget.projectLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.budget.projectLocation._id", Direction.ASC));
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
mongoTemplate.indexOps(Organization.class).ensureIndex(new TextIndexDefinitionBuilder().onField("name").onField("id").onField("additionalIdentifiers._id").build());
mongoTemplate.indexOps(VNLocation.class).ensureIndex(new TextIndexDefinitionBuilder().onField("description").onField("uri").build());
//vietnam specific indexes:
mongoTemplate.indexOps(Release.class).ensureIndex(new Index().on("planning.bidPlanProjectDateApprove", Direction.ASC));
createProcuringEntityIndexes();
logger.info("Added extra Mongo indexes");
ScriptOperations scriptOps = mongoTemplate.scriptOps();
// add script to calculate the percentiles endpoint
URL scriptFile = getClass().getResource("/tenderBidPeriodPercentilesMongo.js");
try {
String scriptText = IOUtils.toString(scriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(scriptText);
scriptOps.register(new NamedMongoScript("tenderBidPeriodPercentiles", script));
} catch (IOException e) {
e.printStackTrace();
}
// add general mongo system helper methods
URL systemScriptFile = getClass().getResource("/mongoSystemScripts.js");
try {
String systemScriptFileText = IOUtils.toString(systemScriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(systemScriptFileText);
scriptOps.execute(script);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.springframework.data.mongodb.core.index.TextIndexDefinition.TextIndexDefinitionBuilder in project spring-data-mongodb by spring-projects.
the class MongoPersistentEntityIndexResolver method potentiallyCreateTextIndexDefinition.
private Collection<? extends IndexDefinitionHolder> potentiallyCreateTextIndexDefinition(MongoPersistentEntity<?> root) {
String name = root.getType().getSimpleName() + "_TextIndex";
if (name.getBytes().length > 127) {
String[] args = ClassUtils.getShortNameAsProperty(root.getType()).split("\\.");
name = "";
Iterator<String> it = Arrays.asList(args).iterator();
while (it.hasNext()) {
if (!it.hasNext()) {
name += it.next() + "_TextIndex";
} else {
name += (it.next().charAt(0) + ".");
}
}
}
TextIndexDefinitionBuilder indexDefinitionBuilder = new TextIndexDefinitionBuilder().named(name);
if (StringUtils.hasText(root.getLanguage())) {
indexDefinitionBuilder.withDefaultLanguage(root.getLanguage());
}
try {
appendTextIndexInformation("", Path.empty(), indexDefinitionBuilder, root, new TextIndexIncludeOptions(IncludeStrategy.DEFAULT), new CycleGuard());
} catch (CyclicPropertyReferenceException e) {
LOGGER.info(e.getMessage());
}
TextIndexDefinition indexDefinition = indexDefinitionBuilder.build();
if (!indexDefinition.hasFieldSpec()) {
return Collections.emptyList();
}
IndexDefinitionHolder holder = new IndexDefinitionHolder("", indexDefinition, root.getCollection());
return Collections.singletonList(holder);
}
use of org.springframework.data.mongodb.core.index.TextIndexDefinition.TextIndexDefinitionBuilder in project oc-explorer by devgateway.
the class AbstractMongoDatabaseConfiguration method createPostImportStructures.
public void createPostImportStructures() {
createCorruptionFlagsIndexes();
// initialize some extra indexes
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("ocid", Direction.ASC).unique());
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PROC_METHOD, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.procurementMethodRationale", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_STATUS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_STATUS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_SUPPLIERS_ID, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_SUPPLIERS_NAME, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_NO_TENDERERS, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_SUBMISSION_METHOD, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.TENDER_PERIOD_END_DATE, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.classification._id", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation._id", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on("tender.items.deliveryLocation.geometry.coordinates", Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.BIDS_DETAILS_TENDERERS_ID, Direction.ASC));
getTemplate().indexOps(Release.class).ensureIndex(new Index().on(MongoConstants.FieldNames.BIDS_DETAILS_VALUE_AMOUNT, Direction.ASC));
getTemplate().indexOps(Organization.class).ensureIndex(new TextIndexDefinitionBuilder().withDefaultLanguage(MongoConstants.MONGO_LANGUAGE).onField("name").onField("id").onField("additionalIdentifiers._id").build());
getTemplate().indexOps(Release.class).ensureIndex(new TextIndexDefinitionBuilder().named("text_search").withDefaultLanguage(MongoConstants.MONGO_LANGUAGE).onFields("tender.title", "tender.description", "tender.procuringEntity.name", "tender.id", "tender.procuringEntity.description", "awards.id", "awards.description", "awards.suppliers.name", "awards.suppliers.description", "ocid", "buyer.name", "buyer.id").build());
getLogger().info("Added extra Mongo indexes");
ScriptOperations scriptOps = getTemplate().scriptOps();
// add script to calculate the percentiles endpoint
URL scriptFile = getClass().getResource("/tenderBidPeriodPercentilesMongo.js");
try {
String scriptText = IOUtils.toString(scriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(scriptText);
scriptOps.register(new NamedMongoScript("tenderBidPeriodPercentiles", script));
} catch (IOException e) {
e.printStackTrace();
}
// add general mongo system helper methods
URL systemScriptFile = getClass().getResource("/mongoSystemScripts.js");
try {
String systemScriptFileText = IOUtils.toString(systemScriptFile);
ExecutableMongoScript script = new ExecutableMongoScript(systemScriptFileText);
scriptOps.execute(script);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations