11
11
12
12
import org .apache .lucene .analysis .TokenStream ;
13
13
import org .apache .lucene .analysis .shingle .ShingleFilter ;
14
- import org .elasticsearch .common .logging .DeprecationCategory ;
15
- import org .elasticsearch .common .logging .DeprecationLogger ;
16
14
import org .elasticsearch .common .settings .Settings ;
17
15
import org .elasticsearch .env .Environment ;
18
16
import org .elasticsearch .index .IndexSettings ;
19
- import org .elasticsearch .index .IndexVersions ;
20
17
import org .elasticsearch .lucene .analysis .miscellaneous .DisableGraphAttribute ;
21
18
22
19
public class ShingleTokenFilterFactory extends AbstractTokenFilterFactory {
23
20
24
- private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger .getLogger (ShingleTokenFilterFactory .class );
25
-
26
21
private final Factory factory ;
27
22
28
- private final IndexSettings indexSettings ;
29
-
30
23
public ShingleTokenFilterFactory (IndexSettings indexSettings , Environment environment , String name , Settings settings ) {
31
24
super (name , settings );
32
- this .indexSettings = indexSettings ;
33
25
int maxAllowedShingleDiff = indexSettings .getMaxShingleDiff ();
34
26
Integer maxShingleSize = settings .getAsInt ("max_shingle_size" , ShingleFilter .DEFAULT_MAX_SHINGLE_SIZE );
35
27
Integer minShingleSize = settings .getAsInt ("min_shingle_size" , ShingleFilter .DEFAULT_MIN_SHINGLE_SIZE );
36
28
Boolean outputUnigrams = settings .getAsBoolean ("output_unigrams" , true );
37
29
38
30
int shingleDiff = maxShingleSize - minShingleSize + (outputUnigrams ? 1 : 0 );
39
31
if (shingleDiff > maxAllowedShingleDiff ) {
40
- if (indexSettings .getIndexVersionCreated ().onOrAfter (IndexVersions .V_7_0_0 )) {
41
- throw new IllegalArgumentException (
42
- "In Shingle TokenFilter the difference between max_shingle_size and min_shingle_size (and +1 if outputting unigrams)"
43
- + " must be less than or equal to: ["
44
- + maxAllowedShingleDiff
45
- + "] but was ["
46
- + shingleDiff
47
- + "]. This limit"
48
- + " can be set by changing the ["
49
- + IndexSettings .MAX_SHINGLE_DIFF_SETTING .getKey ()
50
- + "] index level setting."
51
- );
52
- } else {
53
- DEPRECATION_LOGGER .warn (
54
- DeprecationCategory .ANALYSIS ,
55
- "excessive_shingle_diff" ,
56
- "Deprecated big difference between maxShingleSize and minShingleSize"
57
- + " in Shingle TokenFilter, expected difference must be less than or equal to: ["
58
- + maxAllowedShingleDiff
59
- + "]"
60
- );
61
- }
32
+ throw new IllegalArgumentException (
33
+ "In Shingle TokenFilter the difference between max_shingle_size and min_shingle_size (and +1 if outputting unigrams)"
34
+ + " must be less than or equal to: ["
35
+ + maxAllowedShingleDiff
36
+ + "] but was ["
37
+ + shingleDiff
38
+ + "]. This limit"
39
+ + " can be set by changing the ["
40
+ + IndexSettings .MAX_SHINGLE_DIFF_SETTING .getKey ()
41
+ + "] index level setting."
42
+ );
62
43
}
63
44
64
45
Boolean outputUnigramsIfNoShingles = settings .getAsBoolean ("output_unigrams_if_no_shingles" , false );
@@ -82,17 +63,7 @@ public TokenStream create(TokenStream tokenStream) {
82
63
83
64
@ Override
84
65
public TokenFilterFactory getSynonymFilter () {
85
- if (indexSettings .getIndexVersionCreated ().onOrAfter (IndexVersions .V_7_0_0 )) {
86
- throw new IllegalArgumentException ("Token filter [" + name () + "] cannot be used to parse synonyms" );
87
- } else {
88
- DEPRECATION_LOGGER .warn (
89
- DeprecationCategory .ANALYSIS ,
90
- "synonym_tokenfilters" ,
91
- "Token filter " + name () + "] will not be usable to parse synonym after v7.0"
92
- );
93
- }
94
- return this ;
95
-
66
+ throw new IllegalArgumentException ("Token filter [" + name () + "] cannot be used to parse synonyms" );
96
67
}
97
68
98
69
public Factory getInnerFactory () {
@@ -109,7 +80,7 @@ public static final class Factory implements TokenFilterFactory {
109
80
private final String tokenSeparator ;
110
81
private final String fillerToken ;
111
82
112
- private int minShingleSize ;
83
+ private final int minShingleSize ;
113
84
114
85
private final String name ;
115
86
0 commit comments