Skip to content

Commit f0117e7

Browse files
committed
DATAES-621 - Add missing fieldtypes and parameters to mapping.
Original PR: spring-projects#311
1 parent 490347f commit f0117e7

18 files changed

+787
-148
lines changed

src/main/java/org/springframework/data/elasticsearch/annotations/Field.java

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
/**
5252
* The <em>name</em> to be used to store the field inside the document.
53-
* <p>√5
54-
* If not set, the name of the annotated property is used.
53+
* <p>
54+
* √5 If not set, the name of the annotated property is used.
5555
*
5656
* @since 3.2
5757
*/
@@ -86,4 +86,66 @@
8686
* @since 4.0
8787
*/
8888
int ignoreAbove() default -1;
89+
90+
/**
91+
* @since 4.0
92+
*/
93+
boolean coerce() default true;
94+
95+
/**
96+
* @since 4.0
97+
*/
98+
boolean docValues() default true;
99+
100+
/**
101+
* @since 4.0
102+
*/
103+
boolean ignoreMalformed() default false;
104+
105+
/**
106+
* @since 4.0
107+
*/
108+
IndexOptions indexOptions() default IndexOptions.none;
109+
110+
/**
111+
* @since 4.0
112+
*/
113+
boolean indexPhrases() default false;
114+
115+
/**
116+
* implemented as array to enable the empty default value
117+
*
118+
* @since 4.0
119+
*/
120+
IndexPrefixes[] indexPrefixes() default {};
121+
122+
/**
123+
* @since 4.0
124+
*/
125+
boolean norms() default true;
126+
127+
/**
128+
* @since 4.0
129+
*/
130+
String nullValue() default "";
131+
132+
/**
133+
* @since 4.0
134+
*/
135+
int positionIncrementGap() default -1;
136+
137+
/**
138+
* @since 4.0
139+
*/
140+
Similarity similarity() default Similarity.Default;
141+
142+
/**
143+
* @since 4.0
144+
*/
145+
TermVector termVector() default TermVector.none;
146+
147+
/**
148+
* @since 4.0
149+
*/
150+
double scalingFactor() default 1;
89151
}

src/main/java/org/springframework/data/elasticsearch/annotations/FieldType.java

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,34 @@
2020
* @author Mohsin Husen
2121
* @author Artur Konczak
2222
* @author Zeng Zetang
23+
* @author Peter-Josef Meisch
2324
*/
2425
public enum FieldType {
25-
Text,
26-
Byte,
27-
Short,
28-
Integer,
29-
Long,
30-
Date,
31-
Half_Float,
32-
Float,
33-
Double,
34-
Boolean,
35-
Object,
36-
Auto,
37-
Nested,
38-
Ip,
39-
Attachment,
40-
Keyword
26+
Auto,
27+
Text,
28+
Keyword,
29+
Long,
30+
Integer,
31+
Short,
32+
Byte,
33+
Double,
34+
Float,
35+
Half_Float,
36+
Scaled_Float,
37+
Date,
38+
Date_Nanos,
39+
Boolean,
40+
Binary,
41+
Integer_Range,
42+
Float_Range,
43+
Long_Range,
44+
Double_Range,
45+
Date_Range,
46+
Ip_Range,
47+
Object,
48+
Nested,
49+
Ip,
50+
TokenCount,
51+
Percolator,
52+
Flattened
4153
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.elasticsearch.annotations;
17+
18+
/**
19+
* @author Peter-Josef Meisch
20+
* @since 4.0
21+
*/
22+
public enum IndexOptions {
23+
none, docs, freqs, positions, offsets
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.elasticsearch.annotations;
17+
18+
/**
19+
* @author Peter-Josef Meisch
20+
* @since 4.0
21+
*/
22+
public @interface IndexPrefixes {
23+
static final int MIN_DEFAULT = 2;
24+
static final int MAX_DEFAULT = 2;
25+
26+
int minChars() default MIN_DEFAULT;
27+
28+
int maxChars() default MAX_DEFAULT;
29+
}

src/main/java/org/springframework/data/elasticsearch/annotations/InnerField.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* @author Mohsin Husen
2626
* @author Sascha Woo
2727
* @author Xiao Yu
28+
* @author Peter-Josef Meisch
2829
*/
2930
@Retention(RetentionPolicy.RUNTIME)
3031
@Target(ElementType.FIELD)
@@ -54,4 +55,66 @@
5455
* @since 4.0
5556
*/
5657
int ignoreAbove() default -1;
58+
59+
/**
60+
* @since 4.0
61+
*/
62+
boolean coerce() default true;
63+
64+
/**
65+
* @since 4.0
66+
*/
67+
boolean docValues() default true;
68+
69+
/**
70+
* @since 4.0
71+
*/
72+
boolean ignoreMalformed() default false;
73+
74+
/**
75+
* @since 4.0
76+
*/
77+
IndexOptions indexOptions() default IndexOptions.none;
78+
79+
/**
80+
* @since 4.0
81+
*/
82+
boolean indexPhrases() default false;
83+
84+
/**
85+
* implemented as array to enable the empty default value
86+
*
87+
* @since 4.0
88+
*/
89+
IndexPrefixes[] indexPrefixes() default {};
90+
91+
/**
92+
* @since 4.0
93+
*/
94+
boolean norms() default true;
95+
96+
/**
97+
* @since 4.0
98+
*/
99+
String nullValue() default "";
100+
101+
/**
102+
* @since 4.0
103+
*/
104+
int positionIncrementGap() default -1;
105+
106+
/**
107+
* @since 4.0
108+
*/
109+
Similarity similarity() default Similarity.Default;
110+
111+
/**
112+
* @since 4.0
113+
*/
114+
TermVector termVector() default TermVector.none;
115+
116+
/**
117+
* @since 4.0
118+
*/
119+
double scalingFactor() default 1;
57120
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.elasticsearch.annotations;
17+
18+
/**
19+
* @author Peter-Josef Meisch
20+
* @since 4.0
21+
*/
22+
public enum Similarity {
23+
Default("default"), BM25("BM25"), classic("classic"), Boolean("boolean");
24+
25+
// need to use a custom name because 'boolean' can't be used as enum name
26+
private final String toStringName;
27+
28+
Similarity(String name) {
29+
this.toStringName = name;
30+
}
31+
32+
@Override
33+
public String toString() {
34+
return toStringName;
35+
}
36+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.elasticsearch.annotations;
17+
18+
/**
19+
* @author Peter-Josef Meisch
20+
* @since 4.0
21+
*/
22+
public enum TermVector {
23+
none, no, yes, with_positions, with_offsets, woth_positions_offsets, with_positions_payloads, with_positions_offets_payloads
24+
}

src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
102102
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
103103
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
104+
import org.springframework.data.elasticsearch.core.indexmapping.MappingBuilder;
104105
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
105106
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
106107
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;

src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
8989
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
9090
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
91+
import org.springframework.data.elasticsearch.core.indexmapping.MappingBuilder;
9192
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
9293
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
9394
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;

src/main/java/org/springframework/data/elasticsearch/core/ResourceUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020

2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
23-
2423
import org.springframework.core.io.ClassPathResource;
2524
import org.springframework.util.StreamUtils;
2625

2726
/**
2827
* Utility to read {@link org.springframework.core.io.Resource}s.
2928
*
3029
* @author Mark Paluch
30+
* @author Peter-Josef Meisch
3131
* @since 3.2
3232
*/
33-
abstract class ResourceUtil {
33+
public abstract class ResourceUtil {
3434

3535
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceUtil.class);
3636

0 commit comments

Comments
 (0)