Skip to content

Commit

Permalink
Merge branch 'main' into plugin-aware-thread-context
Browse files Browse the repository at this point in the history
  • Loading branch information
cwperks committed May 31, 2024
2 parents f8cf238 + 6c9603a commit 19155ca
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/assemble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
- name: Setup docker (missing on MacOS)
if: runner.os == 'macos'
uses: douglascamata/setup-docker-macos-action@main
with:
upgrade-qemu: true
- name: Run Gradle (assemble)
run: |
./gradlew assemble --parallel --no-build-cache -PDISABLE_BUILD_CACHE
1 change: 1 addition & 0 deletions CHANGELOG-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add task completion count in search backpressure stats API ([#10028](https://github.com/opensearch-project/OpenSearch/pull/10028/))
- Deprecate CamelCase `PathHierarchy` tokenizer name in favor to lowercase `path_hierarchy` ([#10894](https://github.com/opensearch-project/OpenSearch/pull/10894))
- Breaking change: Do not request "search_pipelines" metrics by default in NodesInfoRequest ([#12497](https://github.com/opensearch-project/OpenSearch/pull/12497))
- Remove deprecated constant META_FIELDS_BEFORE_7DOT8 ([#13860](https://github.com/opensearch-project/OpenSearch/pull/13860))

### Deprecated

Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Remote Store] Upload translog checkpoint as object metadata to translog.tlog([#13637](https://github.com/opensearch-project/OpenSearch/pull/13637))
- Add getMetadataFields to MapperService ([#13819](https://github.com/opensearch-project/OpenSearch/pull/13819))
- [Remote State] Add async remote state deletion task running on an interval, configurable by a setting ([#13131](https://github.com/opensearch-project/OpenSearch/pull/13131))
- Remove deprecated constant META_FIELDS_BEFORE_7DOT8 ([#13860](https://github.com/opensearch-project/OpenSearch/pull/13860))

### Dependencies
- Bump `com.github.spullara.mustache.java:compiler` from 0.9.10 to 0.9.13 ([#13329](https://github.com/opensearch-project/OpenSearch/pull/13329), [#13559](https://github.com/opensearch-project/OpenSearch/pull/13559))
Expand Down Expand Up @@ -43,10 +42,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Remove handling of index.mapper.dynamic in AutoCreateIndex([#13067](https://github.com/opensearch-project/OpenSearch/pull/13067))

### Fixed
- Fix negative RequestStats metric issue ([#13553](https://github.com/opensearch-project/OpenSearch/pull/13553))
- Fix get field mapping API returns 404 error in mixed cluster with multiple versions ([#13624](https://github.com/opensearch-project/OpenSearch/pull/13624))
- Allow clearing `remote_store.compatibility_mode` setting ([#13646](https://github.com/opensearch-project/OpenSearch/pull/13646))
- Fix ReplicaShardBatchAllocator to batch shards without duplicates ([#13710](https://github.com/opensearch-project/OpenSearch/pull/13710))
- Pass parent filter to inner hit query ([#13903](https://github.com/opensearch-project/OpenSearch/pull/13903))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.StreamSupport;

import fixture.s3.S3HttpHandler;
Expand Down Expand Up @@ -206,7 +205,12 @@ public void testRequestStats() throws Exception {
} catch (RepositoryMissingException e) {
return null;
}
}).filter(Objects::nonNull).map(Repository::stats).reduce(RepositoryStats::merge).get();
}).filter(b -> {
if (b instanceof BlobStoreRepository) {
return ((BlobStoreRepository) b).blobStore() != null;
}
return false;
}).map(Repository::stats).reduce(RepositoryStats::merge).get();

Map<BlobStore.Metric, Map<String, Long>> extendedStats = repositoryStats.extendedStats;
Map<String, Long> aggregatedStats = new HashMap<>();
Expand Down
3 changes: 2 additions & 1 deletion release-notes/opensearch.release-notes-2.14.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@
- Improve the error messages for _stats with closed indices ([#13012](https://github.com/opensearch-project/OpenSearch/pull/13012))
- Ignore BaseRestHandler unconsumed content check as it's always consumed. ([#13290](https://github.com/opensearch-project/OpenSearch/pull/13290))
- Fix mapper_parsing_exception when using flat_object fields with names longer than 11 characters ([#13259](https://github.com/opensearch-project/OpenSearch/pull/13259))
- DATETIME_FORMATTER_CACHING_SETTING experimental feature should not default to 'true' ([#13532](https://github.com/opensearch-project/OpenSearch/pull/13532))
- DATETIME_FORMATTER_CACHING_SETTING experimental feature should not default to 'true' ([#13532](https://github.com/opensearch-project/OpenSearch/pull/13532))
- Fix negative RequestStats metric issue ([#13553](https://github.com/opensearch-project/OpenSearch/pull/13553))
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ static Custom fromXContent(XContentParser parser, String name) throws IOExceptio
// handling any Exception is caller's responsibility
return parser.namedObject(Custom.class, name, null);
}

static Custom fromXContent(XContentParser parser) throws IOException {
String currentFieldName = parser.currentName();
return fromXContent(parser, currentFieldName);
}
}

public static final Setting<Integer> DEFAULT_REPLICA_COUNT_SETTING = Setting.intSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public class RemoteClusterStateService implements Closeable {
public static final ChecksumBlobStoreFormat<Metadata.Custom> CUSTOM_METADATA_FORMAT = new ChecksumBlobStoreFormat<>(
"custom",
METADATA_NAME_FORMAT,
Metadata.Custom::fromXContent
null // no need of reader here, as this object is only used to write/serialize the object
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,32 @@ protected void doBuild(SearchContext parentSearchContext, InnerHitsContext inner
}
}
String name = innerHitBuilder.getName() != null ? innerHitBuilder.getName() : nestedObjectMapper.fullPath();
ObjectMapper parentObjectMapper = queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
name,
parentSearchContext,
parentObjectMapper,
nestedObjectMapper
);
setupInnerHitsContext(queryShardContext, nestedInnerHits);
queryShardContext.nestedScope().previousLevel();
innerHitsContext.addInnerHitDefinition(nestedInnerHits);
ObjectMapper parentObjectMapper = queryShardContext.nestedScope().getObjectMapper();
BitSetProducer parentFilter;
if (parentObjectMapper == null) {
parentFilter = queryShardContext.bitsetFilter(Queries.newNonNestedFilter());
} else {
parentFilter = queryShardContext.bitsetFilter(parentObjectMapper.nestedTypeFilter());
}
BitSetProducer previousParentFilter = queryShardContext.getParentFilter();
try {
queryShardContext.setParentFilter(parentFilter);
queryShardContext.nestedScope().nextLevel(nestedObjectMapper);
try {
NestedInnerHitSubContext nestedInnerHits = new NestedInnerHitSubContext(
name,
parentSearchContext,
parentObjectMapper,
nestedObjectMapper
);
setupInnerHitsContext(queryShardContext, nestedInnerHits);
innerHitsContext.addInnerHitDefinition(nestedInnerHits);
} finally {
queryShardContext.nestedScope().previousLevel();
}
} finally {
queryShardContext.setParentFilter(previousParentFilter);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.KnnVectorsFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.util.SPIClassIterator;
import org.opensearch.Build;
Expand Down Expand Up @@ -762,6 +763,7 @@ static void reloadLuceneSPI(ClassLoader loader) {
// Codecs:
PostingsFormat.reloadPostingsFormats(loader);
DocValuesFormat.reloadDocValuesFormats(loader);
KnnVectorsFormat.reloadKnnVectorsFormat(loader);
Codec.reloadCodecs(loader);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,43 @@ public void testInlineLeafInnerHitsNestedQuery() throws Exception {
assertThat(innerHitBuilders.get(leafInnerHits.getName()), Matchers.notNullValue());
}

public void testParentFilterFromInlineLeafInnerHitsNestedQuery() throws Exception {
QueryShardContext queryShardContext = createShardContext();
SearchContext searchContext = mock(SearchContext.class);
when(searchContext.getQueryShardContext()).thenReturn(queryShardContext);

MapperService mapperService = mock(MapperService.class);
IndexSettings settings = new IndexSettings(newIndexMeta("index", Settings.EMPTY), Settings.EMPTY);
when(mapperService.getIndexSettings()).thenReturn(settings);
when(searchContext.mapperService()).thenReturn(mapperService);

InnerHitBuilder leafInnerHits = randomNestedInnerHits();
// Set null for values not related with this test case
leafInnerHits.setScriptFields(null);
leafInnerHits.setHighlightBuilder(null);
leafInnerHits.setSorts(null);

QueryBuilder innerQueryBuilder = spy(new MatchAllQueryBuilder());
when(innerQueryBuilder.toQuery(queryShardContext)).thenAnswer(invoke -> {
QueryShardContext context = invoke.getArgument(0);
if (context.getParentFilter() == null) {
throw new Exception("Expect parent filter to be non-null");
}
return invoke.callRealMethod();
});
NestedQueryBuilder query = new NestedQueryBuilder("nested1", innerQueryBuilder, ScoreMode.None);
query.innerHit(leafInnerHits);
final Map<String, InnerHitContextBuilder> innerHitBuilders = new HashMap<>();
final InnerHitsContext innerHitsContext = new InnerHitsContext();
query.extractInnerHitBuilders(innerHitBuilders);
assertThat(innerHitBuilders.size(), Matchers.equalTo(1));
assertTrue(innerHitBuilders.containsKey(leafInnerHits.getName()));
assertNull(queryShardContext.getParentFilter());
innerHitBuilders.get(leafInnerHits.getName()).build(searchContext, innerHitsContext);
assertNull(queryShardContext.getParentFilter());
verify(innerQueryBuilder).toQuery(queryShardContext);
}

public void testInlineLeafInnerHitsNestedQueryViaBoolQuery() {
InnerHitBuilder leafInnerHits = randomNestedInnerHits();
NestedQueryBuilder nestedQueryBuilder = new NestedQueryBuilder("path", new MatchAllQueryBuilder(), ScoreMode.None).innerHit(
Expand Down

0 comments on commit 19155ca

Please sign in to comment.