30
30
31
31
/**
32
32
* Encapsulates the found data with additional information from the search.
33
- *
33
+ *
34
34
* @param <T> the result data class.
35
35
* @author Peter-Josef Meisch
36
36
* @author Matt Gilene
@@ -48,8 +48,13 @@ public class SearchHit<T> {
48
48
@ Nullable private final NestedMetaData nestedMetaData ;
49
49
@ Nullable private final String routing ;
50
50
@ Nullable private final Explanation explanation ;
51
- @ Nullable private final List <String > matchedQueries ;
51
+ private final List <String > matchedQueries = new ArrayList <>() ;
52
52
53
+ /**
54
+ * @deprecated since 4.2 use
55
+ * {@link #SearchHit(String, String, String, float, Object[], Map, Map, NestedMetaData, Explanation, List, Object)}.
56
+ */
57
+ @ Deprecated
53
58
public SearchHit (@ Nullable String index , @ Nullable String id , @ Nullable String routing , float score ,
54
59
@ Nullable Object [] sortValues , @ Nullable Map <String , List <String >> highlightFields , T content ) {
55
60
this (index , id , routing , score , sortValues , highlightFields , null , null , null , null , content );
@@ -58,8 +63,7 @@ public SearchHit(@Nullable String index, @Nullable String id, @Nullable String r
58
63
public SearchHit (@ Nullable String index , @ Nullable String id , @ Nullable String routing , float score ,
59
64
@ Nullable Object [] sortValues , @ Nullable Map <String , List <String >> highlightFields ,
60
65
@ Nullable Map <String , SearchHits <?>> innerHits , @ Nullable NestedMetaData nestedMetaData ,
61
- @ Nullable Explanation explanation ,
62
- @ Nullable List <String > matchedQueries , T content ) {
66
+ @ Nullable Explanation explanation , @ Nullable List <String > matchedQueries , T content ) {
63
67
this .index = index ;
64
68
this .id = id ;
65
69
this .routing = routing ;
@@ -77,7 +81,10 @@ public SearchHit(@Nullable String index, @Nullable String id, @Nullable String r
77
81
this .nestedMetaData = nestedMetaData ;
78
82
this .explanation = explanation ;
79
83
this .content = content ;
80
- this .matchedQueries = matchedQueries ;
84
+
85
+ if (matchedQueries != null ) {
86
+ this .matchedQueries .addAll (matchedQueries );
87
+ }
81
88
}
82
89
83
90
/**
@@ -125,7 +132,7 @@ public Map<String, List<String>> getHighlightFields() {
125
132
126
133
/**
127
134
* gets the highlight values for a field.
128
- *
135
+ *
129
136
* @param field must not be {@literal null}
130
137
* @return possibly empty List, never null
131
138
*/
@@ -141,7 +148,7 @@ public List<String> getHighlightField(String field) {
141
148
* nested entity class, the returned data will be of this type, otherwise
142
149
* {{@link org.springframework.data.elasticsearch.core.document.SearchDocument}} instances are returned in this
143
150
* {@link SearchHits} object.
144
- *
151
+ *
145
152
* @param name the inner hits name
146
153
* @return {@link SearchHits} if available, otherwise {@literal null}
147
154
*/
@@ -160,7 +167,7 @@ public Map<String, SearchHits<?>> getInnerHits() {
160
167
161
168
/**
162
169
* If this is a nested inner hit, return the nested metadata information
163
- *
170
+ *
164
171
* @return {{@link NestedMetaData}
165
172
* @since 4.1
166
173
*/
0 commit comments