Skip to content

Commit 7745cdb

Browse files
[Backport 2.x] Star tree mapping changes (#15320)
* Star tree mapping changes (#14605) * Star tree mapping changes with feature flag --------- Signed-off-by: Bharathwaj G <bharath78910@gmail.com> * Fixing compatibility breaking checks Signed-off-by: Bharathwaj G <bharath78910@gmail.com> --------- Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
1 parent e076e66 commit 7745cdb

40 files changed

+3117
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2121
- Support filtering on a large list encoded by bitmap ([#14774](https://github.com/opensearch-project/OpenSearch/pull/14774))
2222
- Add slice execution listeners to SearchOperationListener interface ([#15153](https://github.com/opensearch-project/OpenSearch/pull/15153))
2323
- Adding access to noSubMatches and noOverlappingMatches in Hyphenation ([#13895](https://github.com/opensearch-project/OpenSearch/pull/13895))
24+
- Star tree mapping changes ([#14605](https://github.com/opensearch-project/OpenSearch/pull/14605))
25+
2426

2527
### Dependencies
2628
- Bump `netty` from 4.1.111.Final to 4.1.112.Final ([#15081](https://github.com/opensearch-project/OpenSearch/pull/15081))

distribution/src/config/opensearch.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,7 @@ ${path.logs}
125125
# Gates the functionality of enabling Opensearch to use pluggable caches with respective store names via setting.
126126
#
127127
#opensearch.experimental.feature.pluggable.caching.enabled: false
128+
#
129+
# Gates the functionality of star tree index, which improves the performance of search aggregations.
130+
#
131+
#opensearch.experimental.feature.composite_index.star_tree.enabled: false

server/src/internalClusterTest/java/org/opensearch/index/mapper/StarTreeMapperIT.java

Lines changed: 440 additions & 0 deletions
Large diffs are not rendered by default.

server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.opensearch.index.IndexNotFoundException;
8787
import org.opensearch.index.IndexService;
8888
import org.opensearch.index.IndexSettings;
89+
import org.opensearch.index.compositeindex.CompositeIndexValidator;
8990
import org.opensearch.index.mapper.DocumentMapper;
9091
import org.opensearch.index.mapper.MapperService;
9192
import org.opensearch.index.mapper.MapperService.MergeReason;
@@ -1341,6 +1342,10 @@ private static void updateIndexMappingsAndBuildSortOrder(
13411342
}
13421343
}
13431344

1345+
if (mapperService.isCompositeIndexPresent()) {
1346+
CompositeIndexValidator.validate(mapperService, indexService.getCompositeIndexSettings(), indexService.getIndexSettings());
1347+
}
1348+
13441349
if (sourceMetadata == null) {
13451350
// now that the mapping is merged we can validate the index sort.
13461351
// we cannot validate for index shrinking since the mapping is empty

server/src/main/java/org/opensearch/cluster/metadata/MetadataMappingService.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.opensearch.core.common.Strings;
5656
import org.opensearch.core.index.Index;
5757
import org.opensearch.index.IndexService;
58+
import org.opensearch.index.compositeindex.CompositeIndexValidator;
5859
import org.opensearch.index.mapper.DocumentMapper;
5960
import org.opensearch.index.mapper.MapperService;
6061
import org.opensearch.index.mapper.MapperService.MergeReason;
@@ -291,7 +292,7 @@ private ClusterState applyRequest(
291292
// we use the exact same indexService and metadata we used to validate above here to actually apply the update
292293
final Index index = indexMetadata.getIndex();
293294
final MapperService mapperService = indexMapperServices.get(index);
294-
295+
boolean isCompositeFieldPresent = !mapperService.getCompositeFieldTypes().isEmpty();
295296
CompressedXContent existingSource = null;
296297
DocumentMapper existingMapper = mapperService.documentMapper();
297298
if (existingMapper != null) {
@@ -302,6 +303,14 @@ private ClusterState applyRequest(
302303
mappingUpdateSource,
303304
MergeReason.MAPPING_UPDATE
304305
);
306+
307+
CompositeIndexValidator.validate(
308+
mapperService,
309+
indicesService.getCompositeIndexSettings(),
310+
mapperService.getIndexSettings(),
311+
isCompositeFieldPresent
312+
);
313+
305314
CompressedXContent updatedSource = mergedMapper.mappingSource();
306315

307316
if (existingSource != null) {

server/src/main/java/org/opensearch/common/settings/ClusterSettings.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
import org.opensearch.index.ShardIndexingPressureMemoryManager;
118118
import org.opensearch.index.ShardIndexingPressureSettings;
119119
import org.opensearch.index.ShardIndexingPressureStore;
120+
import org.opensearch.index.compositeindex.CompositeIndexSettings;
120121
import org.opensearch.index.remote.RemoteStorePressureSettings;
121122
import org.opensearch.index.remote.RemoteStoreStatsTrackerFactory;
122123
import org.opensearch.index.store.remote.filecache.FileCacheSettings;
@@ -760,7 +761,10 @@ public void apply(Settings value, Settings current, Settings previous) {
760761
RemoteStoreSettings.CLUSTER_REMOTE_MAX_TRANSLOG_READERS,
761762
RemoteStoreSettings.CLUSTER_REMOTE_STORE_TRANSLOG_METADATA,
762763
SearchService.CLUSTER_ALLOW_DERIVED_FIELD_SETTING,
763-
SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED
764+
SystemTemplatesService.SETTING_APPLICATION_BASED_CONFIGURATION_TEMPLATES_ENABLED,
765+
766+
// Composite index settings
767+
CompositeIndexSettings.STAR_TREE_INDEX_ENABLED_SETTING
764768
)
765769
)
766770
);

server/src/main/java/org/opensearch/common/settings/FeatureFlagSettings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected FeatureFlagSettings(
3838
FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
3939
FeatureFlags.PLUGGABLE_CACHE_SETTING,
4040
FeatureFlags.REMOTE_PUBLICATION_EXPERIMENTAL_SETTING,
41-
FeatureFlags.APPLICATION_BASED_CONFIGURATION_TEMPLATES_SETTING
41+
FeatureFlags.APPLICATION_BASED_CONFIGURATION_TEMPLATES_SETTING,
42+
FeatureFlags.STAR_TREE_INDEX_SETTING
4243
);
4344
}

server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.opensearch.index.SearchSlowLog;
5353
import org.opensearch.index.TieredMergePolicyProvider;
5454
import org.opensearch.index.cache.bitset.BitsetFilterCache;
55+
import org.opensearch.index.compositeindex.datacube.startree.StarTreeIndexSettings;
5556
import org.opensearch.index.engine.EngineConfig;
5657
import org.opensearch.index.fielddata.IndexFieldDataService;
5758
import org.opensearch.index.mapper.FieldMapper;
@@ -239,6 +240,15 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
239240
// Settings for concurrent segment search
240241
IndexSettings.INDEX_CONCURRENT_SEGMENT_SEARCH_SETTING,
241242
IndexSettings.ALLOW_DERIVED_FIELDS,
243+
244+
// Settings for star tree index
245+
StarTreeIndexSettings.STAR_TREE_DEFAULT_MAX_LEAF_DOCS,
246+
StarTreeIndexSettings.STAR_TREE_MAX_DIMENSIONS_SETTING,
247+
StarTreeIndexSettings.STAR_TREE_MAX_FIELDS_SETTING,
248+
StarTreeIndexSettings.DEFAULT_METRICS_LIST,
249+
StarTreeIndexSettings.DEFAULT_DATE_INTERVALS,
250+
StarTreeIndexSettings.STAR_TREE_MAX_DATE_INTERVALS_SETTING,
251+
242252
// validate that built-in similarities don't get redefined
243253
Setting.groupSetting("index.similarity.", (s) -> {
244254
Map<String, Settings> groups = s.getAsGroups();

server/src/main/java/org/opensearch/common/util/FeatureFlags.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ public class FeatureFlags {
110110
Property.NodeScope
111111
);
112112

113+
/**
114+
* Gates the functionality of star tree index, which improves the performance of search
115+
* aggregations.
116+
*/
117+
public static final String STAR_TREE_INDEX = "opensearch.experimental.feature.composite_index.star_tree.enabled";
118+
public static final Setting<Boolean> STAR_TREE_INDEX_SETTING = Setting.boolSetting(STAR_TREE_INDEX, false, Property.NodeScope);
119+
113120
private static final List<Setting<Boolean>> ALL_FEATURE_FLAG_SETTINGS = List.of(
114121
REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
115122
EXTENSIONS_SETTING,
@@ -119,7 +126,8 @@ public class FeatureFlags {
119126
TIERED_REMOTE_INDEX_SETTING,
120127
PLUGGABLE_CACHE_SETTING,
121128
REMOTE_PUBLICATION_EXPERIMENTAL_SETTING,
122-
APPLICATION_BASED_CONFIGURATION_TEMPLATES_SETTING
129+
APPLICATION_BASED_CONFIGURATION_TEMPLATES_SETTING,
130+
STAR_TREE_INDEX_SETTING
123131
);
124132

125133
/**

server/src/main/java/org/opensearch/index/IndexModule.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.opensearch.index.cache.query.DisabledQueryCache;
6868
import org.opensearch.index.cache.query.IndexQueryCache;
6969
import org.opensearch.index.cache.query.QueryCache;
70+
import org.opensearch.index.compositeindex.CompositeIndexSettings;
7071
import org.opensearch.index.engine.Engine;
7172
import org.opensearch.index.engine.EngineConfigFactory;
7273
import org.opensearch.index.engine.EngineFactory;
@@ -319,6 +320,7 @@ public Iterator<Setting<?>> settings() {
319320
private final BooleanSupplier allowExpensiveQueries;
320321
private final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories;
321322
private final FileCache fileCache;
323+
private final CompositeIndexSettings compositeIndexSettings;
322324

323325
/**
324326
* Construct the index module for the index with the specified index settings. The index module contains extension points for plugins
@@ -338,7 +340,8 @@ public IndexModule(
338340
final BooleanSupplier allowExpensiveQueries,
339341
final IndexNameExpressionResolver expressionResolver,
340342
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories,
341-
final FileCache fileCache
343+
final FileCache fileCache,
344+
final CompositeIndexSettings compositeIndexSettings
342345
) {
343346
this.indexSettings = indexSettings;
344347
this.analysisRegistry = analysisRegistry;
@@ -351,6 +354,32 @@ public IndexModule(
351354
this.expressionResolver = expressionResolver;
352355
this.recoveryStateFactories = recoveryStateFactories;
353356
this.fileCache = fileCache;
357+
this.compositeIndexSettings = compositeIndexSettings;
358+
}
359+
360+
public IndexModule(
361+
final IndexSettings indexSettings,
362+
final AnalysisRegistry analysisRegistry,
363+
final EngineFactory engineFactory,
364+
final EngineConfigFactory engineConfigFactory,
365+
final Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories,
366+
final BooleanSupplier allowExpensiveQueries,
367+
final IndexNameExpressionResolver expressionResolver,
368+
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories,
369+
final FileCache fileCache
370+
) {
371+
this(
372+
indexSettings,
373+
analysisRegistry,
374+
engineFactory,
375+
engineConfigFactory,
376+
directoryFactories,
377+
allowExpensiveQueries,
378+
expressionResolver,
379+
recoveryStateFactories,
380+
fileCache,
381+
null
382+
);
354383
}
355384

356385
public IndexModule(
@@ -372,6 +401,7 @@ public IndexModule(
372401
allowExpensiveQueries,
373402
expressionResolver,
374403
recoveryStateFactories,
404+
null,
375405
null
376406
);
377407
}
@@ -758,7 +788,8 @@ public IndexService newIndexService(
758788
clusterDefaultRefreshIntervalSupplier,
759789
recoverySettings,
760790
remoteStoreSettings,
761-
fileCache
791+
fileCache,
792+
compositeIndexSettings
762793
);
763794
success = true;
764795
return indexService;

server/src/main/java/org/opensearch/index/IndexService.java

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import org.opensearch.index.cache.IndexCache;
7474
import org.opensearch.index.cache.bitset.BitsetFilterCache;
7575
import org.opensearch.index.cache.query.QueryCache;
76+
import org.opensearch.index.compositeindex.CompositeIndexSettings;
7677
import org.opensearch.index.engine.Engine;
7778
import org.opensearch.index.engine.EngineConfigFactory;
7879
import org.opensearch.index.engine.EngineFactory;
@@ -192,6 +193,7 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
192193
private final RecoverySettings recoverySettings;
193194
private final RemoteStoreSettings remoteStoreSettings;
194195
private final FileCache fileCache;
196+
private final CompositeIndexSettings compositeIndexSettings;
195197

196198
public IndexService(
197199
IndexSettings indexSettings,
@@ -228,7 +230,8 @@ public IndexService(
228230
Supplier<TimeValue> clusterDefaultRefreshIntervalSupplier,
229231
RecoverySettings recoverySettings,
230232
RemoteStoreSettings remoteStoreSettings,
231-
FileCache fileCache
233+
FileCache fileCache,
234+
CompositeIndexSettings compositeIndexSettings
232235
) {
233236
super(indexSettings);
234237
this.allowExpensiveQueries = allowExpensiveQueries;
@@ -306,10 +309,88 @@ public IndexService(
306309
this.translogFactorySupplier = translogFactorySupplier;
307310
this.recoverySettings = recoverySettings;
308311
this.remoteStoreSettings = remoteStoreSettings;
312+
this.compositeIndexSettings = compositeIndexSettings;
309313
this.fileCache = fileCache;
310314
updateFsyncTaskIfNecessary();
311315
}
312316

317+
public IndexService(
318+
IndexSettings indexSettings,
319+
IndexCreationContext indexCreationContext,
320+
NodeEnvironment nodeEnv,
321+
NamedXContentRegistry xContentRegistry,
322+
SimilarityService similarityService,
323+
ShardStoreDeleter shardStoreDeleter,
324+
IndexAnalyzers indexAnalyzers,
325+
EngineFactory engineFactory,
326+
EngineConfigFactory engineConfigFactory,
327+
CircuitBreakerService circuitBreakerService,
328+
BigArrays bigArrays,
329+
ThreadPool threadPool,
330+
ScriptService scriptService,
331+
ClusterService clusterService,
332+
Client client,
333+
QueryCache queryCache,
334+
IndexStorePlugin.DirectoryFactory directoryFactory,
335+
IndexStorePlugin.DirectoryFactory remoteDirectoryFactory,
336+
IndexEventListener eventListener,
337+
Function<IndexService, CheckedFunction<DirectoryReader, DirectoryReader, IOException>> wrapperFactory,
338+
MapperRegistry mapperRegistry,
339+
IndicesFieldDataCache indicesFieldDataCache,
340+
List<SearchOperationListener> searchOperationListeners,
341+
List<IndexingOperationListener> indexingOperationListeners,
342+
NamedWriteableRegistry namedWriteableRegistry,
343+
BooleanSupplier idFieldDataEnabled,
344+
BooleanSupplier allowExpensiveQueries,
345+
IndexNameExpressionResolver expressionResolver,
346+
ValuesSourceRegistry valuesSourceRegistry,
347+
IndexStorePlugin.RecoveryStateFactory recoveryStateFactory,
348+
BiFunction<IndexSettings, ShardRouting, TranslogFactory> translogFactorySupplier,
349+
Supplier<TimeValue> clusterDefaultRefreshIntervalSupplier,
350+
RecoverySettings recoverySettings,
351+
RemoteStoreSettings remoteStoreSettings,
352+
FileCache fileCache
353+
) {
354+
this(
355+
indexSettings,
356+
indexCreationContext,
357+
nodeEnv,
358+
xContentRegistry,
359+
similarityService,
360+
shardStoreDeleter,
361+
indexAnalyzers,
362+
engineFactory,
363+
engineConfigFactory,
364+
circuitBreakerService,
365+
bigArrays,
366+
threadPool,
367+
scriptService,
368+
clusterService,
369+
client,
370+
queryCache,
371+
directoryFactory,
372+
remoteDirectoryFactory,
373+
eventListener,
374+
wrapperFactory,
375+
mapperRegistry,
376+
indicesFieldDataCache,
377+
searchOperationListeners,
378+
indexingOperationListeners,
379+
namedWriteableRegistry,
380+
idFieldDataEnabled,
381+
allowExpensiveQueries,
382+
expressionResolver,
383+
valuesSourceRegistry,
384+
recoveryStateFactory,
385+
translogFactorySupplier,
386+
clusterDefaultRefreshIntervalSupplier,
387+
recoverySettings,
388+
remoteStoreSettings,
389+
fileCache,
390+
null
391+
);
392+
}
393+
313394
public IndexService(
314395
IndexSettings indexSettings,
315396
IndexCreationContext indexCreationContext,
@@ -381,6 +462,7 @@ public IndexService(
381462
clusterDefaultRefreshIntervalSupplier,
382463
recoverySettings,
383464
remoteStoreSettings,
465+
null,
384466
null
385467
);
386468
}
@@ -1123,6 +1205,10 @@ private void rescheduleRefreshTasks() {
11231205
}
11241206
}
11251207

1208+
public CompositeIndexSettings getCompositeIndexSettings() {
1209+
return compositeIndexSettings;
1210+
}
1211+
11261212
/**
11271213
* Shard Store Deleter Interface
11281214
*

0 commit comments

Comments
 (0)