Skip to content

Commit a70324d

Browse files
authored
Merge branch 'main' into skip_date_sub_agg
Signed-off-by: Asim Mahmood <[email protected]>
2 parents f192a4d + 259add3 commit a70324d

18 files changed

+1182
-52
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3838
- [Search Stats] Add search & star-tree search query failure count metrics ([#19210](https://github.com/opensearch-project/OpenSearch/issues/19210))
3939
- [Star-tree] Support for multi-terms aggregation ([#18398](https://github.com/opensearch-project/OpenSearch/issues/18398))
4040
- Add stream search feature flag and auto fallback logic ([#19373](https://github.com/opensearch-project/OpenSearch/pull/19373))
41+
- Implement GRPC Exists, Regexp, and Wildcard queries ([#19392](https://github.com/opensearch-project/OpenSearch/pull/19392))
42+
- Implement GRPC GeoBoundingBox, GeoDistance queries ([#19451](https://github.com/opensearch-project/OpenSearch/pull/19451))
43+
- Implement GRPC Ids, Range, and Terms Set queries ([#19448](https://github.com/opensearch-project/OpenSearch/pull/19448))
44+
- Implement GRPC Nested query ([#19453](https://github.com/opensearch-project/OpenSearch/pull/19453))
4145
- Add sub aggregation support for histogram aggregation using skiplist ([19438](https://github.com/opensearch-project/OpenSearch/pull/19438))
4246

4347
### Changed
@@ -60,6 +64,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6064
- Migrate usages of deprecated `Operations#union` from Lucene ([#19397](https://github.com/opensearch-project/OpenSearch/pull/19397))
6165
- Delegate primitive write methods with ByteSizeCachingDirectory wrapped IndexOutput ([#19432](https://github.com/opensearch-project/OpenSearch/pull/19432))
6266
- Bump opensearch-protobufs dependency to 0.18.0 and update transport-grpc module compatibility ([#19447](https://github.com/opensearch-project/OpenSearch/issues/19447))
67+
- Bump opensearch-protobufs dependency to 0.19.0 ([#19453](https://github.com/opensearch-project/OpenSearch/issues/19453))
6368

6469
### Fixed
6570
- Fix unnecessary refreshes on update preparation failures ([#15261](https://github.com/opensearch-project/OpenSearch/issues/15261))

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ kotlin = "1.7.10"
2222
antlr4 = "4.13.1"
2323
guava = "33.2.1-jre"
2424
gson = "2.13.2"
25-
opensearchprotobufs = "0.18.0"
25+
opensearchprotobufs = "0.19.0"
2626
protobuf = "3.25.8"
2727
jakarta_annotation = "1.3.5"
2828
google_http_client = "1.44.1"

modules/transport-grpc/licenses/protobufs-0.18.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14b425a0cb280ccad20983daeaabf3d1c83c3670

modules/transport-grpc/spi/licenses/protobufs-0.18.0.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14b425a0cb280ccad20983daeaabf3d1c83c3670

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/CollapseBuilderProtoUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.opensearch.search.collapse.CollapseBuilder;
1414

1515
import java.io.IOException;
16+
import java.util.ArrayList;
1617
import java.util.List;
1718

1819
/**
@@ -45,7 +46,10 @@ protected static CollapseBuilder fromProto(FieldCollapse collapseProto) throws I
4546
collapseBuilder.setMaxConcurrentGroupRequests(collapseProto.getMaxConcurrentGroupSearches());
4647
}
4748
if (collapseProto.getInnerHitsCount() > 0) {
48-
List<InnerHitBuilder> innerHitBuilders = InnerHitsBuilderProtoUtils.fromProto(collapseProto.getInnerHitsList());
49+
List<InnerHitBuilder> innerHitBuilders = new ArrayList<>();
50+
for (org.opensearch.protobufs.InnerHits innerHits : collapseProto.getInnerHitsList()) {
51+
innerHitBuilders.add(InnerHitsBuilderProtoUtils.fromProto(innerHits));
52+
}
4953
collapseBuilder.setInnerHits(innerHitBuilders);
5054
}
5155

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/FieldAndFormatProtoUtils.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ private FieldAndFormatProtoUtils() {
3030
* @param fieldAndFormatProto The Protocol Buffer FieldAndFormat to convert
3131
* @return A configured FieldAndFormat instance
3232
*/
33-
protected static FieldAndFormat fromProto(org.opensearch.protobufs.FieldAndFormat fieldAndFormatProto) {
33+
public static FieldAndFormat fromProto(org.opensearch.protobufs.FieldAndFormat fieldAndFormatProto) {
34+
if (fieldAndFormatProto == null) {
35+
throw new IllegalArgumentException("FieldAndFormat protobuf cannot be null");
36+
}
3437

35-
// TODO how is this field used?
36-
// fieldAndFormatProto.getIncludeUnmapped();
37-
return new FieldAndFormat(fieldAndFormatProto.getField(), fieldAndFormatProto.getFormat());
38+
String fieldName = fieldAndFormatProto.getField();
39+
if (fieldName == null || fieldName.trim().isEmpty()) {
40+
throw new IllegalArgumentException("Field name cannot be null or empty");
41+
}
42+
String format = fieldAndFormatProto.hasFormat() ? fieldAndFormatProto.getFormat() : null;
43+
44+
return new FieldAndFormat(fieldName, format);
3845
}
46+
3947
}

modules/transport-grpc/src/main/java/org/opensearch/transport/grpc/proto/request/search/InnerHitsBuilderProtoUtils.java

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,18 @@ public static InnerHitBuilder fromProto(InnerHits innerHits) throws IOException
7575
innerHitBuilder.setStoredFieldNames(innerHits.getStoredFieldsList());
7676
}
7777
if (innerHits.getDocvalueFieldsCount() > 0) {
78-
List<FieldAndFormat> fieldAndFormatList = new ArrayList<>();
78+
List<FieldAndFormat> docvalueFieldsList = new ArrayList<>();
7979
for (org.opensearch.protobufs.FieldAndFormat fieldAndFormat : innerHits.getDocvalueFieldsList()) {
80-
fieldAndFormatList.add(FieldAndFormatProtoUtils.fromProto(fieldAndFormat));
80+
docvalueFieldsList.add(FieldAndFormatProtoUtils.fromProto(fieldAndFormat));
8181
}
82-
innerHitBuilder.setDocValueFields(fieldAndFormatList);
82+
innerHitBuilder.setDocValueFields(docvalueFieldsList);
8383
}
8484
if (innerHits.getFieldsCount() > 0) {
85-
List<FieldAndFormat> fieldAndFormatList = new ArrayList<>();
86-
// TODO: this is not correct, we need to use FieldAndFormatProtoUtils.fromProto() and fix the protobufs in 0.11.0
87-
for (String fieldName : innerHits.getFieldsList()) {
88-
fieldAndFormatList.add(new FieldAndFormat(fieldName, null));
85+
List<FieldAndFormat> fieldsList = new ArrayList<>();
86+
for (org.opensearch.protobufs.FieldAndFormat fieldAndFormat : innerHits.getFieldsList()) {
87+
fieldsList.add(FieldAndFormatProtoUtils.fromProto(fieldAndFormat));
8988
}
90-
innerHitBuilder.setFetchFields(fieldAndFormatList);
89+
innerHitBuilder.setFetchFields(fieldsList);
9190
}
9291
if (innerHits.getScriptFieldsCount() > 0) {
9392
Set<SearchSourceBuilder.ScriptField> scriptFields = new HashSet<>();
@@ -118,24 +117,4 @@ public static InnerHitBuilder fromProto(InnerHits innerHits) throws IOException
118117
return innerHitBuilder;
119118
}
120119

121-
/**
122-
* Converts a list of protobuf InnerHits to a list of OpenSearch InnerHitBuilder objects.
123-
* Each InnerHits protobuf message represents ONE inner hit definition.
124-
*
125-
* @param innerHitsList the list of protobuf InnerHits to convert
126-
* @return the list of converted OpenSearch InnerHitBuilder objects
127-
* @throws IOException if there's an error during parsing
128-
*/
129-
public static List<InnerHitBuilder> fromProto(List<InnerHits> innerHitsList) throws IOException {
130-
if (innerHitsList == null) {
131-
throw new IllegalArgumentException("InnerHits list cannot be null");
132-
}
133-
134-
List<InnerHitBuilder> innerHitBuilders = new ArrayList<>();
135-
for (InnerHits innerHits : innerHitsList) {
136-
innerHitBuilders.add(fromProto(innerHits));
137-
}
138-
return innerHitBuilders;
139-
}
140-
141120
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.transport.grpc.proto.request.search.query;
10+
11+
import org.opensearch.index.query.QueryBuilder;
12+
import org.opensearch.protobufs.QueryContainer;
13+
import org.opensearch.transport.grpc.spi.QueryBuilderProtoConverter;
14+
import org.opensearch.transport.grpc.spi.QueryBuilderProtoConverterRegistry;
15+
16+
/**
17+
* Converter for NestedQuery protobuf messages to OpenSearch QueryBuilder objects.
18+
* Handles the conversion of nested query protobuf messages to OpenSearch NestedQueryBuilder.
19+
*/
20+
public class NestedQueryBuilderProtoConverter implements QueryBuilderProtoConverter {
21+
22+
/**
23+
* Default constructor for NestedQueryBuilderProtoConverter.
24+
*/
25+
public NestedQueryBuilderProtoConverter() {}
26+
27+
private QueryBuilderProtoConverterRegistry registry;
28+
29+
@Override
30+
public void setRegistry(QueryBuilderProtoConverterRegistry registry) {
31+
this.registry = registry;
32+
// The utility class no longer stores the registry statically, it's passed directly to fromProto
33+
}
34+
35+
@Override
36+
public QueryContainer.QueryContainerCase getHandledQueryCase() {
37+
return QueryContainer.QueryContainerCase.NESTED;
38+
}
39+
40+
@Override
41+
public QueryBuilder fromProto(QueryContainer queryContainer) {
42+
if (queryContainer == null || queryContainer.getQueryContainerCase() != QueryContainer.QueryContainerCase.NESTED) {
43+
throw new IllegalArgumentException("QueryContainer must contain a NestedQuery");
44+
}
45+
return NestedQueryBuilderProtoUtils.fromProto(queryContainer.getNested(), registry);
46+
}
47+
}

0 commit comments

Comments
 (0)