Commit 324f282
[9.2] Fix ClassCastException when merging TopHits with mixed sort field types (elastic#141919) (elastic#143068)
* Fix ClassCastException when merging TopHits with mixed sort field types (elastic#141919)
* Fix ClassCastException when merging TopHits with FLOAT/LONG sort types
Fixes ES-14119: Prevents ClassCastException when merging TopHits aggregation
results from different shards with incompatible sort field types (Float vs Long).
Extends SortFieldValidation to handle FLOAT/LONG/DOUBLE mixing by converting
all to DOUBLE, in addition to the existing INT/LONG handling. This ensures
TopDocs can be merged successfully when field mappings differ across shards
during upgrades.
Fix flaky FieldSortIT#testSortMixedFieldTypes by ensuring both index_long
and index_keyword have multiple shards and docs so that merge consistently
sees incompatible sort types (LONG vs STRING) and throws as expected.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Ensure INT/LONG mixes are never converted to DOUBLE (review fix)
Only convert to DOUBLE when the mix involves FLOAT or DOUBLE; make the
condition explicit via involvesFloatingPoint. Add test coverage.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Review fix: clarify comment and exception for multi-index sort type mismatch
Co-authored-by: Cursor <cursoragent@cursor.com>
* [CI] Auto commit changes from spotless
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
* Convert missing value to Double when rewriting sort (elastic#141919)
When merging TopHits with mixed numeric sort types we rewrite to DOUBLE
but were passing the original missing value (e.g. Long) to the new
SortField; Lucene requires Double for Type.DOUBLE.
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>1 parent 2cd2c74 commit 324f282
File tree
6 files changed
+234
-24
lines changed- docs/changelog
- server/src
- internalClusterTest/java/org/elasticsearch/search/sort
- main/java/org/elasticsearch/search
- aggregations/metrics
- sort
- test/java/org/elasticsearch/search/aggregations/metrics
6 files changed
+234
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2162 | 2162 | | |
2163 | 2163 | | |
2164 | 2164 | | |
2165 | | - | |
| 2165 | + | |
2166 | 2166 | | |
2167 | 2167 | | |
2168 | | - | |
| 2168 | + | |
2169 | 2169 | | |
2170 | 2170 | | |
2171 | 2171 | | |
| 2172 | + | |
2172 | 2173 | | |
2173 | 2174 | | |
2174 | 2175 | | |
| 2176 | + | |
2175 | 2177 | | |
| 2178 | + | |
2176 | 2179 | | |
2177 | 2180 | | |
2178 | 2181 | | |
| |||
2188 | 2191 | | |
2189 | 2192 | | |
2190 | 2193 | | |
2191 | | - | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | | - | |
2197 | | - | |
2198 | | - | |
| 2194 | + | |
| 2195 | + | |
2199 | 2196 | | |
2200 | 2197 | | |
| 2198 | + | |
| 2199 | + | |
2201 | 2200 | | |
2202 | 2201 | | |
2203 | 2202 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
| |||
Lines changed: 49 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
135 | 150 | | |
136 | 151 | | |
137 | 152 | | |
| |||
168 | 183 | | |
169 | 184 | | |
170 | 185 | | |
171 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
172 | 203 | | |
173 | 204 | | |
174 | 205 | | |
175 | 206 | | |
176 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
177 | 224 | | |
178 | 225 | | |
179 | 226 | | |
| |||
Lines changed: 97 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| |||
64 | 71 | | |
65 | 72 | | |
66 | 73 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
79 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
80 | 103 | | |
81 | 104 | | |
82 | 105 | | |
83 | 106 | | |
| 107 | + | |
| 108 | + | |
84 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
85 | 116 | | |
86 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
87 | 121 | | |
88 | 122 | | |
89 | 123 | | |
| |||
92 | 126 | | |
93 | 127 | | |
94 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
95 | 137 | | |
96 | 138 | | |
97 | 139 | | |
| |||
122 | 164 | | |
123 | 165 | | |
124 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
125 | 210 | | |
126 | 211 | | |
127 | 212 | | |
| |||
0 commit comments