Commit c2f41cf
Include named queries from rescore contexts in matched_queries array (#18697)
* Fix: Include named queries from rescore contexts in matched_queries array
- Modified QueryRescoreContext to store ParsedQuery instead of just Query
- Updated QueryRescorerBuilder to use context.toQuery() for capturing named queries
- Enhanced MatchedQueriesPhase to collect named queries from all rescore contexts
- Added comprehensive tests for both unit and REST API scenarios
- Resolves inconsistency with Elasticsearch behavior where rescore named queries were not surfaced
- Cleaned up unnecessary comments for better code readability
Signed-off-by: Girish Jeyakumar <[email protected]>
* Address maintainer feedback: update RescoreContext interface design
- Added parsedQuery() method to RescoreContext interface
- Added getParsedQueries() method to RescoreContext interface
- Updated QueryRescoreContext to override interface methods
- Removed instanceof check in MatchedQueriesPhase by using interface method
- Simplified assignment in QueryRescorerBuilder to one line
Signed-off-by: Girish Jeyakumar <[email protected]>
* Complete interface replacement: replace query() with parsedQuery() and getQueries() with getParsedQueries()
- Removed query() method from QueryRescoreContext
- Removed getQueries() method from RescoreContext interface
- Updated all callers to use parsedQuery().query() instead of query()
- Updated DfsPhase to use getParsedQueries() instead of getQueries()
- Updated QueryRescorer to use parsedQuery().query() for rescoring and explanations
- Updated QueryRescorerBuilderTests to use parsedQuery().query()
- This addresses the maintainer's feedback for a cleaner interface design
Signed-off-by: Girish Jeyakumar <[email protected]>
* Finalize interface design and move changelog entry to Added section
- Removed parsedQuery() method from RescoreContext base interface
- Renamed getParsedQuery() to parsedQuery() in QueryRescoreContext for consistency
- Updated all callers to use parsedQuery() method
- Moved changelog entry to 'Added' section (more appropriate than 'Fixed')
- Added proper imports for ParsedQuery to improve code readability
- All tests pass and code formatting is correct
Final interface design:
- RescoreContext: only getParsedQueries() (returns List<ParsedQuery>)
- QueryRescoreContext: parsedQuery() + getParsedQueries() override
- MatchedQueriesPhase: uses getParsedQueries().forEach() for clean iteration
This addresses all maintainer feedback from @mch2 and provides a clean,
well-tested implementation that surfaces named queries from rescore contexts
in the matched_queries array.
Signed-off-by: Girish Jeyakumar <[email protected]>
* Maintain backward compatibility for RescoreContext public API
- Restore getQueries() method for backward compatibility
- Add getParsedQueries() method for new functionality
Signed-off-by: Girish Jeyakumar <[email protected]>
* Fix mixed cluster test failure by updating skip version to 3.2.0
Signed-off-by: girish jeyakumar <[email protected]>
---------
Signed-off-by: Girish Jeyakumar <[email protected]>
Signed-off-by: girish jeyakumar <[email protected]>
Signed-off-by: Marc Handalian <[email protected]>
Co-authored-by: Girish Jeyakumar <[email protected]>
Co-authored-by: Marc Handalian <[email protected]>1 parent e1fc79e commit c2f41cf
File tree
8 files changed
+180
-14
lines changed- rest-api-spec/src/main/resources/rest-api-spec/test/search
- server/src
- main/java/org/opensearch/search
- dfs
- fetch/subphase
- rescore
- test/java/org/opensearch/search/rescore
8 files changed
+180
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 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 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
| |||
Lines changed: 15 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
123 | | - | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
193 | | - | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
200 | 202 | | |
201 | 203 | | |
202 | 204 | | |
203 | | - | |
204 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
209 | | - | |
| 215 | + | |
210 | 216 | | |
211 | 217 | | |
212 | | - | |
213 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
214 | 221 | | |
215 | 222 | | |
216 | 223 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
96 | 104 | | |
Lines changed: 45 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
205 | 249 | | |
206 | 250 | | |
207 | 251 | | |
| |||
0 commit comments