mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-08 13:12:10 +00:00
DATAES-211 - enhance multi field support as multifield type is removed
This commit is contained in:
parent
09455006ab
commit
61880671a4
@ -25,9 +25,9 @@ import java.lang.annotation.Target;
|
|||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface NestedField {
|
public @interface InnerField {
|
||||||
|
|
||||||
String dotSuffix();
|
String suffix();
|
||||||
|
|
||||||
FieldType type();
|
FieldType type();
|
||||||
|
|
@ -30,5 +30,5 @@ public @interface MultiField {
|
|||||||
|
|
||||||
public Field mainField();
|
public Field mainField();
|
||||||
|
|
||||||
public NestedField[] otherFields() default {};
|
public InnerField[] otherFields() default {};
|
||||||
}
|
}
|
||||||
|
@ -268,8 +268,8 @@ class MappingBuilder {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private static void addNestedFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
private static void addNestedFieldMapping(XContentBuilder builder, java.lang.reflect.Field field,
|
||||||
NestedField annotation) throws IOException {
|
InnerField annotation) throws IOException {
|
||||||
builder.startObject(field.getName() + "." + annotation.dotSuffix());
|
builder.startObject(annotation.suffix());
|
||||||
//builder.field(FIELD_STORE, annotation.store());
|
//builder.field(FIELD_STORE, annotation.store());
|
||||||
if (FieldType.Auto != annotation.type()) {
|
if (FieldType.Auto != annotation.type()) {
|
||||||
builder.field(FIELD_TYPE, annotation.type().name().toLowerCase());
|
builder.field(FIELD_TYPE, annotation.type().name().toLowerCase());
|
||||||
@ -298,8 +298,8 @@ class MappingBuilder {
|
|||||||
builder.startObject("fields");
|
builder.startObject("fields");
|
||||||
//add standard field
|
//add standard field
|
||||||
addSingleFieldMapping(builder, field, annotation.mainField(),nestedOrObjectField);
|
addSingleFieldMapping(builder, field, annotation.mainField(),nestedOrObjectField);
|
||||||
for (NestedField nestedField : annotation.otherFields()) {
|
for (InnerField innerField : annotation.otherFields()) {
|
||||||
addNestedFieldMapping(builder, field, nestedField);
|
addNestedFieldMapping(builder, field, innerField);
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
@ -26,7 +26,7 @@ import org.springframework.data.annotation.Id;
|
|||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||||
import org.springframework.data.elasticsearch.annotations.NestedField;
|
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple type to test facets
|
* Simple type to test facets
|
||||||
@ -45,8 +45,8 @@ public class ArticleEntity {
|
|||||||
@MultiField(
|
@MultiField(
|
||||||
mainField = @Field(type = String, index = analyzed),
|
mainField = @Field(type = String, index = analyzed),
|
||||||
otherFields = {
|
otherFields = {
|
||||||
@NestedField(dotSuffix = "untouched", type = String, store = true, index = not_analyzed),
|
@InnerField(suffix = "untouched", type = String, store = true, index = not_analyzed),
|
||||||
@NestedField(dotSuffix = "sort", type = String, store = true, indexAnalyzer = "keyword")
|
@InnerField(suffix = "sort", type = String, store = true, indexAnalyzer = "keyword")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
private List<String> authors = new ArrayList<String>();
|
private List<String> authors = new ArrayList<String>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user