mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 03:52:10 +00:00
DATAES-639 - Polishing.
This commit is contained in:
parent
a9c3058bef
commit
165e02d6e7
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.annotations;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
@ -24,6 +22,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
@ -42,6 +42,7 @@ public @interface Field {
|
||||
|
||||
/**
|
||||
* Alias for {@link #name}.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
@AliasFor("name")
|
||||
@ -49,7 +50,9 @@ public @interface Field {
|
||||
|
||||
/**
|
||||
* The <em>name</em> to be used to store the field inside the document.
|
||||
* <p>If not set, the name of the annotated property is used.
|
||||
* <p>√5
|
||||
* If not set, the name of the annotated property is used.
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
@AliasFor("value")
|
||||
|
@ -27,7 +27,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.elasticsearch.annotations.CompletionContext;
|
||||
@ -364,7 +363,7 @@ class MappingBuilder {
|
||||
searchAnalyzer = fieldAnnotation.searchAnalyzer();
|
||||
normalizer = fieldAnnotation.normalizer();
|
||||
copyTo = fieldAnnotation.copyTo();
|
||||
ignoreAbove = fieldAnnotation.ignoreAbove();
|
||||
ignoreAbove = fieldAnnotation.ignoreAbove() >= 0 ? fieldAnnotation.ignoreAbove() : null;
|
||||
} else if (annotation instanceof InnerField) {
|
||||
// @InnerField
|
||||
InnerField fieldAnnotation = (InnerField) annotation;
|
||||
@ -377,7 +376,7 @@ class MappingBuilder {
|
||||
analyzer = fieldAnnotation.analyzer();
|
||||
searchAnalyzer = fieldAnnotation.searchAnalyzer();
|
||||
normalizer = fieldAnnotation.normalizer();
|
||||
ignoreAbove = fieldAnnotation.ignoreAbove();
|
||||
ignoreAbove = fieldAnnotation.ignoreAbove() >= 0 ? fieldAnnotation.ignoreAbove() : null;
|
||||
} else {
|
||||
throw new IllegalArgumentException("annotation must be an instance of @Field or @InnerField");
|
||||
}
|
||||
@ -385,9 +384,11 @@ class MappingBuilder {
|
||||
if (!nestedOrObjectField) {
|
||||
builder.field(FIELD_STORE, store);
|
||||
}
|
||||
|
||||
if (fielddata) {
|
||||
builder.field(FIELD_DATA, fielddata);
|
||||
}
|
||||
|
||||
if (type != FieldType.Auto) {
|
||||
builder.field(FIELD_TYPE, type.name().toLowerCase());
|
||||
|
||||
@ -395,22 +396,28 @@ class MappingBuilder {
|
||||
builder.field(FIELD_FORMAT, dateFormat == DateFormat.custom ? datePattern : dateFormat.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!index) {
|
||||
builder.field(FIELD_INDEX, index);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(analyzer)) {
|
||||
builder.field(FIELD_INDEX_ANALYZER, analyzer);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(searchAnalyzer)) {
|
||||
builder.field(FIELD_SEARCH_ANALYZER, searchAnalyzer);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(normalizer)) {
|
||||
builder.field(FIELD_NORMALIZER, normalizer);
|
||||
}
|
||||
|
||||
if (copyTo != null && copyTo.length > 0) {
|
||||
builder.field(FIELD_COPY_TO, copyTo);
|
||||
}
|
||||
if (ignoreAbove != -1) {
|
||||
|
||||
if (ignoreAbove != null) {
|
||||
Assert.isTrue(ignoreAbove >= 0, "ignore_above must be a positive value");
|
||||
builder.field(FIELD_IGNORE_ABOVE, ignoreAbove);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user