9
9
10
10
package org .elasticsearch .search .sort ;
11
11
12
+ import org .apache .http .util .EntityUtils ;
12
13
import org .apache .lucene .tests .util .TestUtil ;
13
14
import org .apache .lucene .util .BytesRef ;
14
15
import org .apache .lucene .util .UnicodeUtil ;
20
21
import org .elasticsearch .action .search .SearchRequestBuilder ;
21
22
import org .elasticsearch .action .search .SearchResponse ;
22
23
import org .elasticsearch .action .search .ShardSearchFailure ;
24
+ import org .elasticsearch .client .Request ;
25
+ import org .elasticsearch .client .Response ;
26
+ import org .elasticsearch .client .RestClient ;
23
27
import org .elasticsearch .cluster .metadata .IndexMetadata ;
24
28
import org .elasticsearch .common .settings .Settings ;
25
29
import org .elasticsearch .core .Strings ;
36
40
import org .elasticsearch .search .SearchHits ;
37
41
import org .elasticsearch .test .ESIntegTestCase ;
38
42
import org .elasticsearch .test .InternalSettingsPlugin ;
43
+ import org .elasticsearch .test .junit .annotations .TestIssueLogging ;
39
44
import org .elasticsearch .xcontent .XContentBuilder ;
40
45
import org .elasticsearch .xcontent .XContentFactory ;
41
46
import org .elasticsearch .xcontent .XContentType ;
84
89
import static org .hamcrest .Matchers .not ;
85
90
import static org .hamcrest .Matchers .nullValue ;
86
91
92
+ @ TestIssueLogging (
93
+ issueUrl = "https://github.com/elastic/elasticsearch/issues/129445" ,
94
+ value = "org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction:DEBUG,"
95
+ + "org.elasticsearch.action.search.SearchPhaseController:DEBUG,"
96
+ + "org.elasticsearch.search:TRACE"
97
+ )
87
98
public class FieldSortIT extends ESIntegTestCase {
88
99
public static class CustomScriptPlugin extends MockScriptPlugin {
89
100
@ Override
@@ -112,6 +123,10 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
112
123
return Arrays .asList (InternalSettingsPlugin .class , CustomScriptPlugin .class );
113
124
}
114
125
126
+ protected boolean addMockHttpTransport () {
127
+ return false ;
128
+ }
129
+
115
130
public void testIssue8226 () {
116
131
int numIndices = between (5 , 10 );
117
132
final boolean useMapping = randomBoolean ();
@@ -2145,7 +2160,7 @@ public void testLongSortOptimizationCorrectResults() {
2145
2160
);
2146
2161
}
2147
2162
2148
- public void testSortMixedFieldTypes () {
2163
+ public void testSortMixedFieldTypes () throws IOException {
2149
2164
assertAcked (
2150
2165
prepareCreate ("index_long" ).setMapping ("foo" , "type=long" ),
2151
2166
prepareCreate ("index_integer" ).setMapping ("foo" , "type=integer" ),
@@ -2159,6 +2174,16 @@ public void testSortMixedFieldTypes() {
2159
2174
prepareIndex ("index_keyword" ).setId ("1" ).setSource ("foo" , "123" ).get ();
2160
2175
refresh ();
2161
2176
2177
+ // for debugging, we try to see where the documents are located
2178
+ try (RestClient restClient = createRestClient ()) {
2179
+ Request checkShardsRequest = new Request (
2180
+ "GET" ,
2181
+ "/_cat/shards/index_long,index_double,index_keyword?format=json&h=index,node,shard,prirep,state,docs,index"
2182
+ );
2183
+ Response response = restClient .performRequest (checkShardsRequest );
2184
+ logger .info ("FieldSortIT#testSortMixedFieldTypes document distribution: " + EntityUtils .toString (response .getEntity ()));
2185
+ }
2186
+
2162
2187
{ // mixing long and integer types is ok, as we convert integer sort to long sort
2163
2188
assertNoFailures (prepareSearch ("index_long" , "index_integer" ).addSort (new FieldSortBuilder ("foo" )).setSize (10 ));
2164
2189
}
0 commit comments