35
35
import org .elasticsearch .search .DocValueFormat ;
36
36
import org .elasticsearch .search .SearchHit ;
37
37
import org .elasticsearch .search .fetch .FetchSubPhase ;
38
- import org .elasticsearch .search .fetch .subphase .DocValueFieldsContext .FieldAndFormat ;
38
+ import org .elasticsearch .search .fetch .subphase .FetchDocValuesContext .FieldAndFormat ;
39
39
import org .elasticsearch .search .internal .SearchContext ;
40
40
41
41
import java .io .IOException ;
51
51
import static org .elasticsearch .search .DocValueFormat .withNanosecondResolution ;
52
52
53
53
/**
54
- * Query sub phase which pulls data from doc values
54
+ * Fetch sub phase which pulls data from doc values.
55
55
*
56
56
* Specifying {@code "docvalue_fields": ["field1", "field2"]}
57
57
*/
58
- public final class DocValueFieldsFetchSubPhase implements FetchSubPhase {
58
+ public final class FetchDocValuesPhase implements FetchSubPhase {
59
59
60
60
private static final String USE_DEFAULT_FORMAT = "use_field_mapping" ;
61
61
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger (
62
- LogManager .getLogger (DocValueFieldsFetchSubPhase .class ));
62
+ LogManager .getLogger (FetchDocValuesPhase .class ));
63
63
64
64
@ Override
65
65
public void hitsExecute (SearchContext context , SearchHit [] hits ) throws IOException {
66
66
67
67
if (context .collapse () != null ) {
68
68
// retrieve the `doc_value` associated with the collapse field
69
69
String name = context .collapse ().getFieldName ();
70
- if (context .docValueFieldsContext () == null ) {
71
- context .docValueFieldsContext (new DocValueFieldsContext (
70
+ if (context .docValuesContext () == null ) {
71
+ context .docValuesContext (new FetchDocValuesContext (
72
72
Collections .singletonList (new FieldAndFormat (name , null ))));
73
- } else if (context .docValueFieldsContext ().fields ().stream ().map (ff -> ff .field ).anyMatch (name ::equals ) == false ) {
74
- context .docValueFieldsContext ().fields ().add (new FieldAndFormat (name , null ));
73
+ } else if (context .docValuesContext ().fields ().stream ().map (ff -> ff .field ).anyMatch (name ::equals ) == false ) {
74
+ context .docValuesContext ().fields ().add (new FieldAndFormat (name , null ));
75
75
}
76
76
}
77
77
78
- if (context .docValueFieldsContext () == null ) {
78
+ if (context .docValuesContext () == null ) {
79
79
return ;
80
80
}
81
81
82
82
hits = hits .clone (); // don't modify the incoming hits
83
83
Arrays .sort (hits , Comparator .comparingInt (SearchHit ::docId ));
84
84
85
- if (context .docValueFieldsContext ().fields ().stream ()
85
+ if (context .docValuesContext ().fields ().stream ()
86
86
.map (f -> f .format )
87
87
.filter (USE_DEFAULT_FORMAT ::equals )
88
88
.findAny ()
@@ -91,7 +91,7 @@ public void hitsExecute(SearchContext context, SearchHit[] hits) throws IOExcept
91
91
"ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore." );
92
92
}
93
93
94
- for (FieldAndFormat fieldAndFormat : context .docValueFieldsContext ().fields ()) {
94
+ for (FieldAndFormat fieldAndFormat : context .docValuesContext ().fields ()) {
95
95
String field = fieldAndFormat .field ;
96
96
MappedFieldType fieldType = context .mapperService ().fieldType (field );
97
97
if (fieldType != null ) {
0 commit comments