@@ -105,66 +105,6 @@ public final class IndexSortConfig {
105105 Setting .Property .ServerlessPublic
106106 );
107107
108- private static String validateMissingValue (String missing ) {
109- if ("_last" .equals (missing ) == false && "_first" .equals (missing ) == false ) {
110- throw new IllegalArgumentException ("Illegal missing value:[" + missing + "], " + "must be one of [_last, _first]" );
111- }
112- return missing ;
113- }
114-
115- private static SortOrder parseOrderMode (String value ) {
116- try {
117- return SortOrder .fromString (value );
118- } catch (Exception e ) {
119- throw new IllegalArgumentException ("Illegal sort order:" + value );
120- }
121- }
122-
123- private static MultiValueMode parseMultiValueMode (String value ) {
124- MultiValueMode mode = MultiValueMode .fromString (value );
125- if (mode != MultiValueMode .MAX && mode != MultiValueMode .MIN ) {
126- throw new IllegalArgumentException (
127- "Illegal index sort mode:[" + mode + "], " + "must be one of [" + MultiValueMode .MAX + ", " + MultiValueMode .MIN + "]"
128- );
129- }
130- return mode ;
131- }
132-
133- private static void checkSizeMismatch (String firstKey , List <?> first , String secondKey , List <?> second ) {
134- if (first .size () != second .size ()) {
135- throw new IllegalArgumentException (firstKey + ":" + first + " " + secondKey + ":" + second + ", size mismatch" );
136- }
137- }
138-
139- private static void validateSortSettings (Settings settings ) {
140- if (INDEX_SORT_FIELD_SETTING .exists (settings ) == false ) {
141- for (Setting <?> setting : new Setting <?>[] { INDEX_SORT_ORDER_SETTING , INDEX_SORT_MODE_SETTING , INDEX_SORT_MISSING_SETTING }) {
142- if (setting .exists (settings )) {
143- throw new IllegalArgumentException (
144- "setting [" + setting .getKey () + "] requires [" + INDEX_SORT_FIELD_SETTING .getKey () + "] to be configured"
145- );
146- }
147- }
148- }
149-
150- List <String > fields = INDEX_SORT_FIELD_SETTING .get (settings );
151-
152- if (INDEX_SORT_ORDER_SETTING .exists (settings )) {
153- var order = INDEX_SORT_ORDER_SETTING .get (settings );
154- checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_ORDER_SETTING .getKey (), order );
155- }
156-
157- if (INDEX_SORT_MODE_SETTING .exists (settings )) {
158- var mode = INDEX_SORT_MODE_SETTING .get (settings );
159- checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_MODE_SETTING .getKey (), mode );
160- }
161-
162- if (INDEX_SORT_MISSING_SETTING .exists (settings )) {
163- var missing = INDEX_SORT_MISSING_SETTING .get (settings );
164- checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_MISSING_SETTING .getKey (), missing );
165- }
166- }
167-
168108 public static class IndexSortConfigDefaults {
169109 public static final FieldSortSpec [] TIME_SERIES_SORT , TIMESTAMP_SORT , HOSTNAME_TIMESTAMP_SORT , HOSTNAME_TIMESTAMP_BWC_SORT ;
170110
@@ -245,6 +185,66 @@ public static List<String> getDefaultSortMissing(Settings settings) {
245185 }
246186 }
247187
188+ private static String validateMissingValue (String missing ) {
189+ if ("_last" .equals (missing ) == false && "_first" .equals (missing ) == false ) {
190+ throw new IllegalArgumentException ("Illegal missing value:[" + missing + "], " + "must be one of [_last, _first]" );
191+ }
192+ return missing ;
193+ }
194+
195+ private static SortOrder parseOrderMode (String value ) {
196+ try {
197+ return SortOrder .fromString (value );
198+ } catch (Exception e ) {
199+ throw new IllegalArgumentException ("Illegal sort order:" + value );
200+ }
201+ }
202+
203+ private static MultiValueMode parseMultiValueMode (String value ) {
204+ MultiValueMode mode = MultiValueMode .fromString (value );
205+ if (mode != MultiValueMode .MAX && mode != MultiValueMode .MIN ) {
206+ throw new IllegalArgumentException (
207+ "Illegal index sort mode:[" + mode + "], " + "must be one of [" + MultiValueMode .MAX + ", " + MultiValueMode .MIN + "]"
208+ );
209+ }
210+ return mode ;
211+ }
212+
213+ private static void checkSizeMismatch (String firstKey , List <?> first , String secondKey , List <?> second ) {
214+ if (first .size () != second .size ()) {
215+ throw new IllegalArgumentException (firstKey + ":" + first + " " + secondKey + ":" + second + ", size mismatch" );
216+ }
217+ }
218+
219+ private static void validateSortSettings (Settings settings ) {
220+ if (INDEX_SORT_FIELD_SETTING .exists (settings ) == false ) {
221+ for (Setting <?> setting : new Setting <?>[] { INDEX_SORT_ORDER_SETTING , INDEX_SORT_MODE_SETTING , INDEX_SORT_MISSING_SETTING }) {
222+ if (setting .exists (settings )) {
223+ throw new IllegalArgumentException (
224+ "setting [" + setting .getKey () + "] requires [" + INDEX_SORT_FIELD_SETTING .getKey () + "] to be configured"
225+ );
226+ }
227+ }
228+ }
229+
230+ List <String > fields = INDEX_SORT_FIELD_SETTING .get (settings );
231+
232+ if (INDEX_SORT_ORDER_SETTING .exists (settings )) {
233+ var order = INDEX_SORT_ORDER_SETTING .get (settings );
234+ checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_ORDER_SETTING .getKey (), order );
235+ }
236+
237+ if (INDEX_SORT_MODE_SETTING .exists (settings )) {
238+ var mode = INDEX_SORT_MODE_SETTING .get (settings );
239+ checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_MODE_SETTING .getKey (), mode );
240+ }
241+
242+ if (INDEX_SORT_MISSING_SETTING .exists (settings )) {
243+ var missing = INDEX_SORT_MISSING_SETTING .get (settings );
244+ checkSizeMismatch (INDEX_SORT_FIELD_SETTING .getKey (), fields , INDEX_SORT_MISSING_SETTING .getKey (), missing );
245+ }
246+ }
247+
248248 // visible for tests
249249 final FieldSortSpec [] sortSpecs ;
250250 private final IndexVersion indexCreatedVersion ;
0 commit comments