Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
7aa71c5
Fix test failure
kkrik-es Feb 1, 2024
bf946a9
Fix test failure
kkrik-es Feb 1, 2024
0fa5a7e
Merge branch 'elastic:main' into fix/103567
kkrik-es Feb 1, 2024
87cfbbd
Merge branch 'main' into fix/103567
kkrik-es Feb 2, 2024
a3a2ac0
Nest pass-through objects within objects
kkrik-es Feb 2, 2024
3dda19d
Merge remote-tracking branch 'origin/fix/103567' into fix/103567
kkrik-es Feb 2, 2024
beea734
Support numeric fields as pass-through dimensions
kkrik-es Feb 2, 2024
2e18f8b
Update docs/changelog/105073.yaml
kkrik-es Feb 2, 2024
cbb1368
Merge branch 'main' into fix/103567-2
kkrik-es Feb 5, 2024
cb94c8a
fix tests
kkrik-es Feb 5, 2024
af6e8a5
Merge remote-tracking branch 'origin/fix/103567-2' into fix/103567-2
kkrik-es Feb 5, 2024
61d37a7
fix tests
kkrik-es Feb 5, 2024
0ddecbd
refactor dimension property
kkrik-es Feb 5, 2024
fa065b0
fix yaml
kkrik-es Feb 5, 2024
c712893
add numeric to routing builder
kkrik-es Feb 5, 2024
03784f7
fix violation
kkrik-es Feb 5, 2024
5c23358
fix yaml versions
kkrik-es Feb 5, 2024
d73c472
handle all numeric values in dimension fields
kkrik-es Feb 6, 2024
86257db
Merge branch 'main' into fix/103567-2
kkrik-es Feb 12, 2024
e2887a0
use shardId in TSDB doc id
kkrik-es Feb 13, 2024
846649b
spotless fix
kkrik-es Feb 13, 2024
f464b6e
test fixes
kkrik-es Feb 13, 2024
7363869
Merge branch 'main' into fix/103567-2
kkrik-es Feb 13, 2024
605cdf3
index version guard
kkrik-es Feb 14, 2024
8f56346
test fix
kkrik-es Feb 14, 2024
93787f9
revert shardId changes
kkrik-es Feb 14, 2024
b098202
add routing id field mapper
kkrik-es Feb 14, 2024
0e67c67
Merge branch 'main' into fix/103567-3
kkrik-es Feb 14, 2024
916e7d5
Update docs/changelog/105501.yaml
kkrik-es Feb 14, 2024
7ea7feb
fix shrunk test
kkrik-es Feb 14, 2024
2cb890b
Merge remote-tracking branch 'origin/fix/103567-3' into fix/103567-3
kkrik-es Feb 14, 2024
6ab5a3f
use SortedDocValuesField
kkrik-es Feb 14, 2024
2f27478
fix tests
kkrik-es Feb 15, 2024
c13e0ff
delete unused yaml
kkrik-es Feb 15, 2024
1f18603
submit test fixes
kkrik-es Feb 19, 2024
a6d916e
Merge branch 'main' into fix/103567-3
kkrik-es Feb 19, 2024
72cd225
sync
kkrik-es Feb 19, 2024
30b4dbb
restrict id override to latest version
kkrik-es Feb 19, 2024
8cd5456
update painless path
kkrik-es Feb 19, 2024
302701b
test fix
kkrik-es Mar 4, 2024
b14e774
Merge branch 'main' into fix/103567-3
kkrik-es Mar 4, 2024
dc0a887
check for invalid id
kkrik-es Mar 4, 2024
f14721e
fix painless tests
kkrik-es Mar 4, 2024
c7a9ebc
restore bwc routing changes
kkrik-es Mar 4, 2024
4b1d532
add unittest
kkrik-es Mar 5, 2024
cd4fb92
refactor passthrough test
kkrik-es Mar 5, 2024
ebd631b
Merge branch 'main' into fix/103567-3
kkrik-es Mar 6, 2024
ed7a007
address comments
kkrik-es Mar 7, 2024
0823128
remove redundant variable
kkrik-es Mar 7, 2024
1ce6618
remove assert
kkrik-es Mar 7, 2024
1930c59
fix id test
kkrik-es Mar 7, 2024
5a0d8c9
fix painless
kkrik-es Mar 7, 2024
5d7ba13
skip storing routing field
kkrik-es Mar 7, 2024
d35603c
skip generating the id when available
kkrik-es Mar 7, 2024
5203068
skip assert on routing in TranslogWriter
kkrik-es Mar 7, 2024
4646c8c
skip id mismatch assert
kkrik-es Mar 7, 2024
5531cbc
Introduce TimeSeriesRoutingIdFieldMapper
kkrik-es Mar 7, 2024
d67555c
Update docs/changelog/106080.yaml
kkrik-es Mar 7, 2024
7492ea2
remove changelog from parent pr
kkrik-es Mar 8, 2024
d52a8ea
Merge remote-tracking branch 'origin/fix/103567-4' into fix/103567-4
kkrik-es Mar 8, 2024
afa88ad
comment changes
kkrik-es Mar 8, 2024
e916599
retrieve routing from id in FieldsVisitor
kkrik-es Mar 8, 2024
2e660d8
delete debug stmt
kkrik-es Mar 8, 2024
b8c0704
Delete docs/changelog/106080.yaml
kkrik-es Mar 8, 2024
043175d
skip padding in routing
kkrik-es Mar 8, 2024
be79cc6
Merge remote-tracking branch 'origin/fix/103567-4' into fix/103567-4
kkrik-es Mar 8, 2024
ae83930
Skip comparing passed with generated id
kkrik-es Mar 9, 2024
67de8ab
Merge branch 'main' into fix/103567-4
kkrik-es Mar 11, 2024
ce45c70
Merge branch 'main' into fix/103567-4
kkrik-es Mar 11, 2024
ad26e6b
revert change from #105881, leads to test failures
kkrik-es Mar 11, 2024
19ea1dd
revert
kkrik-es Mar 11, 2024
dca4683
Revert "retrieve routing from id in FieldsVisitor"
kkrik-es Mar 12, 2024
fb3287e
get routing from DocumentParserContext
kkrik-es Mar 12, 2024
24e02f3
get routing from DocumentParserContext
kkrik-es Mar 12, 2024
8409795
Merge branch 'main' into fix/103567-4
kkrik-es Mar 12, 2024
7084ede
get routing from DocumentParserContext
kkrik-es Mar 12, 2024
64d2908
log info msg in SnapshotsService
kkrik-es Mar 12, 2024
ec5d4d9
Merge branch 'main' into fix/103567-4
kkrik-es Mar 12, 2024
866e4a9
revert change in SnapshotsService
kkrik-es Mar 12, 2024
84d2aa7
refactoring
kkrik-es Mar 13, 2024
50c6ce7
spotless fix
kkrik-es Mar 13, 2024
f166b7a
Merge branch 'main' into fix/103567-4
kkrik-es Mar 13, 2024
976cc9b
check for id mismatch
kkrik-es Mar 13, 2024
81e7356
remove unused variable
kkrik-es Mar 13, 2024
d2b7c40
bwc in PainlessExecuteAction
kkrik-es Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.OnScriptError;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.index.mapper.TimeSeriesRoutingHashFieldMapper;
import org.elasticsearch.index.query.AbstractQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.SearchExecutionContext;
Expand Down Expand Up @@ -808,13 +810,18 @@ private static Response prepareRamIndex(
try (IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(defaultAnalyzer))) {
BytesReference document = request.contextSetup.document;
XContentType xContentType = request.contextSetup.xContentType;
String id;
if (indexService.getIndexSettings().getMode() == IndexMode.TIME_SERIES) {
id = null; // The id gets auto generated for time series indices.
} else {
id = "_id";
}
SourceToParse sourceToParse = new SourceToParse(id, document, xContentType);

SourceToParse sourceToParse = (indexService.getIndexSettings().getMode() == IndexMode.TIME_SERIES)
? new SourceToParse(
null,
document,
xContentType,
indexService.getIndexSettings().getIndexVersionCreated().onOrAfter(IndexVersions.TIME_SERIES_ROUTING_HASH_IN_ID)
? TimeSeriesRoutingHashFieldMapper.DUMMY_ENCODED_VALUE
: null
)
: new SourceToParse("_id", document, xContentType);

DocumentMapper documentMapper = indexService.mapperService().documentMapper();
if (documentMapper == null) {
documentMapper = DocumentMapper.createEmpty(indexService.mapperService());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void parse(DocumentParserContext context) throws IOException {
if (parent == null) {
throw new IllegalArgumentException("[parent] is missing for join field [" + name() + "]");
}
if (context.sourceToParse().routing() == null) {
if (context.routing() == null) {
throw new IllegalArgumentException("[routing] is missing for join field [" + name() + "]");
}
String fieldName = fieldType().joiner.parentJoinField(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,7 @@ private static Engine.Result performOpOnReplica(
indexRequest.id(),
indexRequest.source(),
indexRequest.getContentType(),
indexRequest.routing(),
Map.of(),
DocumentSizeObserver.EMPTY_INSTANCE
indexRequest.routing()
);
result = replica.applyIndexOperationOnReplica(
primaryResponse.getSeqNo(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public Index getConcreteWriteIndex(IndexAbstraction ia, Metadata metadata) {

@Override
public int route(IndexRouting indexRouting) {
return indexRouting.indexShard(id, routing, contentType, source);
return indexRouting.indexShard(id, routing, contentType, source, this::routing);
}

public IndexRequest setRequireAlias(boolean requireAlias) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.elasticsearch.common.util.ByteUtils;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.mapper.TimeSeriesRoutingHashFieldMapper;
import org.elasticsearch.transport.Transports;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentParser.Token;
Expand All @@ -35,6 +37,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Predicate;
Expand Down Expand Up @@ -74,7 +77,13 @@ private IndexRouting(IndexMetadata metadata) {
* Called when indexing a document to generate the shard id that should contain
* a document with the provided parameters.
*/
public abstract int indexShard(String id, @Nullable String routing, XContentType sourceType, BytesReference source);
public abstract int indexShard(
String id,
@Nullable String routing,
XContentType sourceType,
BytesReference source,
Consumer<String> routingHashSetter
);

/**
* Called when updating a document to generate the shard id that should contain
Expand Down Expand Up @@ -153,7 +162,13 @@ public void process(IndexRequest indexRequest) {
}

@Override
public int indexShard(String id, @Nullable String routing, XContentType sourceType, BytesReference source) {
public int indexShard(
String id,
@Nullable String routing,
XContentType sourceType,
BytesReference source,
Consumer<String> routingHashSetter
) {
if (id == null) {
throw new IllegalStateException("id is required and should have been set by process");
}
Expand Down Expand Up @@ -237,12 +252,14 @@ public void collectSearchShards(String routing, IntConsumer consumer) {
public static class ExtractFromSource extends IndexRouting {
private final Predicate<String> isRoutingPath;
private final XContentParserConfiguration parserConfig;
private final boolean trackTimeSeriesRoutingHash;

ExtractFromSource(IndexMetadata metadata) {
super(metadata);
if (metadata.isRoutingPartitionedIndex()) {
throw new IllegalArgumentException("routing_partition_size is incompatible with routing_path");
}
trackTimeSeriesRoutingHash = metadata.getCreationVersion().onOrAfter(IndexVersions.TIME_SERIES_ROUTING_HASH_IN_ID);
List<String> routingPaths = metadata.getRoutingPaths();
isRoutingPath = Regex.simpleMatcher(routingPaths.toArray(String[]::new));
this.parserConfig = XContentParserConfiguration.EMPTY.withFiltering(Set.copyOf(routingPaths), null, true);
Expand All @@ -256,10 +273,20 @@ public boolean matchesField(String fieldName) {
public void process(IndexRequest indexRequest) {}

@Override
public int indexShard(String id, @Nullable String routing, XContentType sourceType, BytesReference source) {
public int indexShard(
String id,
@Nullable String routing,
XContentType sourceType,
BytesReference source,
Consumer<String> routingHashSetter
) {
assert Transports.assertNotTransportThread("parsing the _source can get slow");
checkNoRouting(routing);
return hashToShardId(hashSource(sourceType, source).buildHash(IndexRouting.ExtractFromSource::defaultOnEmpty));
int hash = hashSource(sourceType, source).buildHash(IndexRouting.ExtractFromSource::defaultOnEmpty);
if (trackTimeSeriesRoutingHash) {
routingHashSetter.accept(TimeSeriesRoutingHashFieldMapper.encode(hash));
}
return hashToShardId(hash);
}

public String createId(XContentType sourceType, BytesReference source, byte[] suffix) {
Expand Down Expand Up @@ -334,16 +361,13 @@ private void extractItem(String path, XContentParser source) throws IOException
source.nextToken();
break;
case VALUE_STRING:
case VALUE_NUMBER:
hashes.add(new NameAndHash(new BytesRef(path), hash(new BytesRef(source.text()))));
source.nextToken();
break;
case VALUE_NULL:
source.nextToken();
break;
case VALUE_NUMBER: // allow parsing numbers assuming routing fields are always keyword fields
hashes.add(new NameAndHash(new BytesRef(path), hash(new BytesRef(source.text()))));
source.nextToken();
break;
default:
throw new ParsingException(
source.getTokenLocation(),
Expand Down
19 changes: 19 additions & 0 deletions server/src/main/java/org/elasticsearch/index/IndexMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.index.mapper.RoutingFieldMapper;
import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.mapper.TimeSeriesIdFieldMapper;
import org.elasticsearch.index.mapper.TimeSeriesRoutingHashFieldMapper;
import org.elasticsearch.index.mapper.TsidExtractingIdFieldMapper;

import java.io.IOException;
Expand Down Expand Up @@ -92,6 +93,12 @@ public MetadataFieldMapper timeSeriesIdFieldMapper() {
return null;
}

@Override
public MetadataFieldMapper timeSeriesRoutingHashFieldMapper() {
// non time-series indices must not have a TimeSeriesRoutingIdFieldMapper
return null;
}

@Override
public IdFieldMapper idFieldMapperWithoutFieldData() {
return ProvidedIdFieldMapper.NO_FIELD_DATA;
Expand Down Expand Up @@ -185,6 +192,11 @@ public MetadataFieldMapper timeSeriesIdFieldMapper() {
return TimeSeriesIdFieldMapper.INSTANCE;
}

@Override
public MetadataFieldMapper timeSeriesRoutingHashFieldMapper() {
return TimeSeriesRoutingHashFieldMapper.INSTANCE;
}

public IdFieldMapper idFieldMapperWithoutFieldData() {
return TsidExtractingIdFieldMapper.INSTANCE;
}
Expand Down Expand Up @@ -322,6 +334,13 @@ public String getName() {
*/
public abstract MetadataFieldMapper timeSeriesIdFieldMapper();

/**
* Return an instance of the {@link TimeSeriesRoutingHashFieldMapper} that generates
* the _ts_routing_hash field. The field mapper will be added to the list of the metadata
* field mappers for the index.
*/
public abstract MetadataFieldMapper timeSeriesRoutingHashFieldMapper();

/**
* How {@code time_series_dimension} fields are handled by indices in this mode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private static IndexVersion def(int id, Version luceneVersion) {
public static final IndexVersion UPGRADE_LUCENE_9_9_2 = def(8_502_00_0, Version.LUCENE_9_9_2);
public static final IndexVersion TIME_SERIES_ID_HASHING = def(8_502_00_1, Version.LUCENE_9_9_2);
public static final IndexVersion UPGRADE_TO_LUCENE_9_10 = def(8_503_00_0, Version.LUCENE_9_10_0);
public static final IndexVersion TIME_SERIES_ROUTING_HASH_IN_ID = def(8_504_00_0, Version.LUCENE_9_10_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ boolean useTSDBDocValuesFormat(final String field) {

private boolean excludeFields(String fieldName) {
// Avoid using tsdb codec for fields like _seq_no, _primary_term.
// But _tsid should always use the tesbd codec.
return fieldName.startsWith("_") && fieldName.equals("_tsid") == false;
// But _tsid and _ts_routing_hash should always use the tsdb codec.
return fieldName.startsWith("_") && fieldName.equals("_tsid") == false && fieldName.equals("_ts_routing_hash") == false;
}

private boolean isTimeSeriesModeIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
import org.elasticsearch.index.mapper.VersionFieldMapper;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.plugins.internal.DocumentSizeObserver;

import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -254,14 +252,7 @@ private LeafReader getDelegate() {
private LeafReader createInMemoryLeafReader() {
assert Thread.holdsLock(this);
final ParsedDocument parsedDocs = documentParser.parseDocument(
new SourceToParse(
operation.id(),
operation.source(),
XContentHelper.xContentType(operation.source()),
operation.routing(),
Map.of(),
DocumentSizeObserver.EMPTY_INSTANCE
),
new SourceToParse(operation.id(), operation.source(), XContentHelper.xContentType(operation.source()), operation.routing()),
mappingLookup
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public ParsedDocument parseDocument(SourceToParse source, MappingLookup mappingL
context.version(),
context.seqID(),
context.id(),
source.routing(),
context.routing(),
context.reorderParentAndGetDocs(),
context.sourceToParse().source(),
context.sourceToParse().getXContentType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField;
import org.elasticsearch.common.time.DateFormatter;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.IndexAnalyzers;
import org.elasticsearch.xcontent.FilterXContentParserWrapper;
Expand Down Expand Up @@ -231,6 +232,10 @@ public final SourceToParse sourceToParse() {
return this.sourceToParse;
}

public final String routing() {
return mappingParserContext.getIndexSettings().getMode() == IndexMode.TIME_SERIES ? null : sourceToParse.routing();
}

/**
* Add the given {@code field} to the set of ignored fields.
*/
Expand Down
45 changes: 28 additions & 17 deletions server/src/main/java/org/elasticsearch/index/mapper/IdLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,24 @@ final class TsIdLoader implements IdLoader {
}

public IdLoader.Leaf leaf(LeafStoredFieldLoader loader, LeafReader reader, int[] docIdsInLeaf) throws IOException {
IndexRouting.ExtractFromSource.Builder[] builders = new IndexRouting.ExtractFromSource.Builder[docIdsInLeaf.length];
for (int i = 0; i < builders.length; i++) {
builders[i] = indexRouting.builder();
}
IndexRouting.ExtractFromSource.Builder[] builders = null;
if (indexRouting != null) {
builders = new IndexRouting.ExtractFromSource.Builder[docIdsInLeaf.length];
for (int i = 0; i < builders.length; i++) {
builders[i] = indexRouting.builder();
}

for (String routingField : routingPaths) {
// Routing field must always be keyword fields, so it is ok to use SortedSetDocValues directly here.
SortedSetDocValues dv = DocValues.getSortedSet(reader, routingField);
for (int i = 0; i < docIdsInLeaf.length; i++) {
int docId = docIdsInLeaf[i];
var builder = builders[i];
if (dv.advanceExact(docId)) {
for (int j = 0; j < dv.docValueCount(); j++) {
BytesRef routingValue = dv.lookupOrd(dv.nextOrd());
builder.addMatching(routingField, routingValue);
for (String routingField : routingPaths) {
// Routing field must always be keyword fields, so it is ok to use SortedSetDocValues directly here.
SortedSetDocValues dv = DocValues.getSortedSet(reader, routingField);
for (int i = 0; i < docIdsInLeaf.length; i++) {
int docId = docIdsInLeaf[i];
var builder = builders[i];
if (dv.advanceExact(docId)) {
for (int j = 0; j < dv.docValueCount(); j++) {
BytesRef routingValue = dv.lookupOrd(dv.nextOrd());
builder.addMatching(routingField, routingValue);
}
}
}
}
Expand All @@ -100,9 +103,17 @@ public IdLoader.Leaf leaf(LeafStoredFieldLoader loader, LeafReader reader, int[]
assert found;
assert timestampDocValues.docValueCount() == 1;
long timestamp = timestampDocValues.nextValue();

var routingBuilder = builders[i];
ids[i] = TsidExtractingIdFieldMapper.createId(false, routingBuilder, tsid, timestamp, new byte[16]);
if (builders != null) {
var routingBuilder = builders[i];
ids[i] = TsidExtractingIdFieldMapper.createId(false, routingBuilder, tsid, timestamp, new byte[16]);
} else {
SortedDocValues routingHashDocValues = DocValues.getSorted(reader, TimeSeriesRoutingHashFieldMapper.NAME);
found = routingHashDocValues.advanceExact(docId);
assert found;
BytesRef routingHashBytes = routingHashDocValues.lookupOrd(routingHashDocValues.ordValue());
int routingHash = TimeSeriesRoutingHashFieldMapper.decode(Uid.decodeId(routingHashBytes.bytes));
ids[i] = TsidExtractingIdFieldMapper.createId(routingHash, tsid, timestamp);
}
}
return new TsIdLeaf(docIdsInLeaf, ids);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public boolean required() {

@Override
public void preParse(DocumentParserContext context) {
String routing = context.sourceToParse().routing();
String routing = context.routing();
if (routing != null) {
context.doc().add(new StringField(fieldType().name(), routing, Field.Store.YES));
context.addToFieldNames(fieldType().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public SourceToParse(String id, BytesReference source, XContentType xContentType
this(id, source, xContentType, null, Map.of(), DocumentSizeObserver.EMPTY_INSTANCE);
}

public SourceToParse(String id, BytesReference source, XContentType xContentType, String routing) {
this(id, source, xContentType, routing, Map.of(), DocumentSizeObserver.EMPTY_INSTANCE);
}

public BytesReference source() {
return this.source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ public void postParse(DocumentParserContext context) throws IOException {
? timeSeriesIdBuilder.buildLegacyTsid().toBytesRef()
: timeSeriesIdBuilder.buildTsidHash().toBytesRef();
context.doc().add(new SortedDocValuesField(fieldType().name(), timeSeriesId));
TsidExtractingIdFieldMapper.createField(context, timeSeriesIdBuilder.routingBuilder, timeSeriesId);
TsidExtractingIdFieldMapper.createField(
context,
getIndexVersionCreated(context).before(IndexVersions.TIME_SERIES_ROUTING_HASH_IN_ID)
? timeSeriesIdBuilder.routingBuilder
: null,
timeSeriesId
);
}

private IndexVersion getIndexVersionCreated(final DocumentParserContext context) {
Expand Down
Loading