@Override public org.bson.Document getIndexOptions() { return indexDefinition.getIndexOptions(); } }
/** * Include given fields with default weight. * * @param fieldnames * @return */ public TextIndexDefinitionBuilder onFields(String... fieldnames) { for (String fieldname : fieldnames) { onField(fieldname); } return this; }
/** * Specifies TTL in seconds. * * @param value * @return * @since 1.5 */ public Index expire(long value) { return expire(value, TimeUnit.SECONDS); }
@SuppressWarnings("deprecation") protected IndexDefinitionHolder createCompoundIndexDefinition(String dotPath, String collection, CompoundIndex index, MongoPersistentEntity<?> entity) { CompoundIndexDefinition indexDefinition = new CompoundIndexDefinition( resolveCompoundIndexKeyFromStringDefinition(dotPath, index.def())); if (!index.useGeneratedName()) { indexDefinition.named(pathAwareIndexName(index.name(), dotPath, null)); } if (index.unique()) { indexDefinition.unique(); } if (index.sparse()) { indexDefinition.sparse(); } if (index.background()) { indexDefinition.background(); } return new IndexDefinitionHolder(dotPath, indexDefinition, collection); }
/** * Creates a {@link TextIndexDefinition} for all fields in the document. * * @return */ public static TextIndexDefinition forAllFields() { return new TextIndexDefinitionBuilder().onAllFields().build(); }
Mono<String> createIndex(IndexDefinitionHolder indexDefinition) { JustOnceLogger.logWarnIndexCreationConfigurationChange(this.getClass().getName()); return operationsProvider.indexOps(indexDefinition.getCollection()).ensureIndex(indexDefinition) // .onErrorResume(ReactiveMongoPersistentEntityIndexCreator::isDataIntegrityViolation, e -> translateException(e, indexDefinition)); }
private void checkForAndCreateIndexes(MongoPersistentEntity<?> entity) { if (entity.isAnnotationPresent(Document.class)) { for (IndexDefinition indexDefinition : indexResolver.resolveIndexFor(entity.getTypeInformation())) { JustOnceLogger.logWarnIndexCreationConfigurationChange(this.getClass().getName()); IndexDefinitionHolder indexToCreate = indexDefinition instanceof IndexDefinitionHolder ? (IndexDefinitionHolder) indexDefinition : new IndexDefinitionHolder("", indexDefinition, entity.getCollection()); createIndex(indexToCreate); } } }
/** * Get {@link TextIndexDefinitionBuilder} to create {@link TextIndexDefinition}. * * @return */ public static TextIndexDefinitionBuilder builder() { return new TextIndexDefinitionBuilder(); }
/** * Create new {@link PartialIndexFilter} for given {@link CriteriaDefinition filter expression}. * * @param where must not be {@literal null}. * @return */ public static PartialIndexFilter of(CriteriaDefinition where) { return new PartialIndexFilter(where); }
/** * Returns whether the {@link IndexField} is a geo index field. * * @return true if type is {@link Type#GEO}. */ public boolean isGeo() { return Type.GEO.equals(type); }
/** * Creates a new {@link MongoPersistentEntityIndexCreator} for the given {@link MongoMappingContext} and * {@link MongoDbFactory}. * * @param mappingContext must not be {@literal null}. * @param indexOperationsProvider must not be {@literal null}. */ public MongoPersistentEntityIndexCreator(MongoMappingContext mappingContext, IndexOperationsProvider indexOperationsProvider) { this(mappingContext, indexOperationsProvider, IndexResolver.create(mappingContext)); }
/** * Creates a text {@link IndexField} for the given key. * * @since 1.6 */ public static IndexField text(String key, Float weight) { return new IndexField(key, null, Type.TEXT, weight); }
@Override public org.bson.Document getIndexKeys() { return indexDefinition.getIndexKeys(); }
public TextIndexDefinitionBuilder() { this.instance = new TextIndexDefinition(); }
/** * Include given field with default weight. * * @param fieldname * @return */ public TextIndexDefinitionBuilder onField(String fieldname) { return onField(fieldname, 1F); }
/** * Create new {@link PartialIndexFilter} for given {@link DBObject filter expression}. * * @param where must not be {@literal null}. * @return */ public static PartialIndexFilter of(Document where) { return new PartialIndexFilter(where); }
/** * Returns whether the {@link IndexField} is a text index field. * * @return true if type is {@link Type#TEXT} * @since 1.6 */ public boolean isText() { return Type.TEXT.equals(type); }
/** * Creates a new {@link ReactiveMongoPersistentEntityIndexCreator} for the given {@link MongoMappingContext}, * {@link ReactiveIndexOperationsProvider}. * * @param mappingContext must not be {@literal null}. * @param operationsProvider must not be {@literal null}. */ public ReactiveMongoPersistentEntityIndexCreator(MongoMappingContext mappingContext, ReactiveIndexOperationsProvider operationsProvider) { this(mappingContext, operationsProvider, IndexResolver.create(mappingContext)); }
/** * Creates a geo {@link IndexField} for the given key. * * @param key must not be {@literal null} or empty. * @return */ public static IndexField geo(String key) { return new IndexField(key, null, Type.GEO); }