Skip to content

Commit 0cc20be

Browse files
retadeshsidd
authored andcommitted
Revert "Removing unused fetch sub phase processor initialization during fetch… (opensearch-project#12503)" (opensearch-project#13486)
This reverts commit da5b205. Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 2188899 commit 0cc20be

File tree

9 files changed

+68
-125
lines changed

9 files changed

+68
-125
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7070
- Refactoring globMatch using simpleMatchWithNormalizedStrings from Regex ([#13104](https://github.com/opensearch-project/OpenSearch/pull/13104))
7171
- [BWC and API enforcement] Reconsider the breaking changes check policy to detect breaking changes against released versions ([#13292](https://github.com/opensearch-project/OpenSearch/pull/13292))
7272
- Switch to macos-13 runner for precommit and assemble github actions due to macos-latest is now arm64 ([#13412](https://github.com/opensearch-project/OpenSearch/pull/13412))
73+
- [Revert] Prevent unnecessary fetch sub phase processor initialization during fetch phase execution ([#12503](https://github.com/opensearch-project/OpenSearch/pull/12503))
7374

7475
### Deprecated
7576

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: test_1
5+
body:
6+
settings:
7+
number_of_replicas: 0
8+
mappings:
9+
properties:
10+
list_id:
11+
type: integer
12+
names:
13+
type: nested
14+
properties:
15+
full_name:
16+
type: text
17+
18+
- do:
19+
bulk:
20+
refresh: true
21+
body:
22+
- index:
23+
_index: test_1
24+
_id: 1
25+
- list_id: 1
26+
names:
27+
- full_name: John Doe
28+
- full_name: John Micheal Doe
29+
- index:
30+
_index: test_1
31+
_id: 2
32+
- list_id: 2
33+
names:
34+
- full_name: Jane Doe
35+
- full_name: Jane Michelle Doe
36+
37+
---
38+
"Include inner hits in top hits":
39+
- do:
40+
search:
41+
rest_total_hits_as_int: true
42+
body:
43+
query:
44+
nested:
45+
path: names
46+
query:
47+
match:
48+
names.full_name: Doe
49+
inner_hits: { }
50+
size: 0
51+
aggs:
52+
lists:
53+
terms:
54+
field: list_id
55+
aggs:
56+
top_result:
57+
top_hits:
58+
size: 10
59+
60+
- length: { hits.hits: 0 }
61+
- length: { aggregations.lists.buckets: 2 }
62+
- length: { aggregations.lists.buckets.0.top_result.hits.hits: 1 }
63+
- length: { aggregations.lists.buckets.0.top_result.hits.hits.0.inner_hits.names.hits.hits: 2 }
64+
- length: { aggregations.lists.buckets.1.top_result.hits.hits: 1 }
65+
- length: { aggregations.lists.buckets.1.top_result.hits.hits.0.inner_hits.names.hits.hits: 2 }

server/src/main/java/org/opensearch/search/fetch/FetchContext.java

-8
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ public boolean includeNamedQueriesScore() {
192192
return searchContext.includeNamedQueriesScore();
193193
}
194194

195-
public boolean hasInnerHits() {
196-
return searchContext.hasInnerHits();
197-
}
198-
199195
/**
200196
* Configuration for returning inner hits
201197
*/
@@ -217,10 +213,6 @@ public FetchFieldsContext fetchFieldsContext() {
217213
return searchContext.fetchFieldsContext();
218214
}
219215

220-
public boolean hasScriptFields() {
221-
return searchContext.hasScriptFields();
222-
}
223-
224216
/**
225217
* Configuration for script fields
226218
*/

server/src/main/java/org/opensearch/search/fetch/subphase/InnerHitsContext.java

-5
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ public String getName() {
119119
return name;
120120
}
121121

122-
@Override
123-
public boolean hasInnerHits() {
124-
return childInnerHits != null;
125-
}
126-
127122
@Override
128123
public InnerHitsContext innerHits() {
129124
return childInnerHits;

server/src/main/java/org/opensearch/search/fetch/subphase/InnerHitsPhase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public InnerHitsPhase(FetchPhase fetchPhase) {
6464

6565
@Override
6666
public FetchSubPhaseProcessor getProcessor(FetchContext searchContext) {
67-
if (searchContext.hasInnerHits() == false) {
67+
if (searchContext.innerHits() == null) {
6868
return null;
6969
}
7070
Map<String, InnerHitsContext.InnerHitSubContext> innerHits = searchContext.innerHits().getInnerHits();

server/src/main/java/org/opensearch/search/fetch/subphase/ScriptFieldsPhase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public final class ScriptFieldsPhase implements FetchSubPhase {
5454

5555
@Override
5656
public FetchSubPhaseProcessor getProcessor(FetchContext context) {
57-
if (context.hasScriptFields() == false) {
57+
if (context.scriptFields() == null) {
5858
return null;
5959
}
6060
List<ScriptFieldsContext.ScriptField> scriptFields = context.scriptFields().fields();

server/src/main/java/org/opensearch/search/internal/SearchContext.java

-4
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ public final void close() {
194194

195195
public abstract void highlight(SearchHighlightContext highlight);
196196

197-
public boolean hasInnerHits() {
198-
return innerHitsContext != null;
199-
}
200-
201197
public InnerHitsContext innerHits() {
202198
if (innerHitsContext == null) {
203199
innerHitsContext = new InnerHitsContext();

server/src/test/java/org/opensearch/search/fetch/subphase/InnerHitsPhaseTests.java

-53
This file was deleted.

server/src/test/java/org/opensearch/search/fetch/subphase/ScriptFieldsPhaseTests.java

-53
This file was deleted.

0 commit comments

Comments
 (0)