Polishing.

Reformat code. Tweak documentation wording and callout syntax.

See #3914, see #3901
Original pull request: #3915.
This commit is contained in:
Mark Paluch
2022-01-12 15:57:14 +01:00
parent 7f223d1332
commit e9c15eb169
4 changed files with 20 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@ import org.springframework.util.Assert;
* Unless specified otherwise the index name will be created out of the keys/path involved in the index. <br />
* {@link TextIndexed} properties are collected into a single index that covers the detected fields. <br />
* {@link java.util.Map} like structures, unless annotated with {@link WildcardIndexed}, are skipped because the
* {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the index.
* {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the
* index.
*
* @author Christoph Strobl
* @author Thomas Darimont

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -354,7 +354,7 @@ public class MongoPersistentEntityIndexResolver implements IndexResolver {
indexDefinitionBuilder.withLanguageOverride(persistentProperty.getFieldName());
}
if(persistentProperty.isMap()) {
if (persistentProperty.isMap()) {
return;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -319,7 +319,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
class IndexOnLevelZeroWithExplicityNamedField {
@Indexed @Field("customFieldName") String namedProperty;
@Indexed
@Field("customFieldName") String namedProperty;
}
@Document
@@ -427,7 +428,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class IndexOnMetaAnnotatedField {
@Field("_name") @IndexedFieldAnnotation String lastname;
@Field("_name")
@IndexedFieldAnnotation String lastname;
}
/**
@@ -1366,10 +1368,9 @@ public class MongoPersistentEntityIndexResolverUnitTests {
});
assertThat(indices.get(2)).satisfies(it -> {
assertThat(it.getIndexKeys()).containsEntry("withOptions.$**", 1);
assertThat(it.getIndexOptions()).containsEntry("name",
"withOptions.idx")
.containsEntry("collation", new org.bson.Document("locale", "en_US"))
.containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
assertThat(it.getIndexOptions()).containsEntry("name", "withOptions.idx")
.containsEntry("collation", new org.bson.Document("locale", "en_US"))
.containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
});
}
@@ -1491,7 +1492,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class SimilarityHolingBean {
@Indexed @Field("norm") String normalProperty;
@Indexed
@Field("norm") String normalProperty;
@Field("similarityL") private List<SimilaritySibling> listOfSimilarilyNamedEntities = null;
}
@@ -1654,7 +1656,8 @@ public class MongoPersistentEntityIndexResolverUnitTests {
@Document
class WithHashedIndexOnId {
@HashIndexed @Id String id;
@HashIndexed
@Id String id;
}
@Document

View File

@@ -409,9 +409,9 @@ This event guarantees that the context is fully initialized.
Note that at this time other components, especially bean factories might have access to the MongoDB database.
[WARNING]
===
`Map` like structures, unless annotated with `@WildcardIndexed`, are skipped by the `IndexResolver` because the _map key_, which cannot be resolved from static metadata, needs to be part of the index definition.
===
====
``Map``-like properties are skipped by the `IndexResolver` unless annotated with `@WildcardIndexed` because the _map key_ must be part of the index definition. Since the purpose of maps is the usage of dynamic keys and values, the keys cannot be resolved from static mapping metadata.
====
.Programmatic Index Creation for a single Domain Type
====