Skip to content

Commit

Permalink
Merge branch 'main' into remove-apm-user
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 18, 2024
2 parents 8ec516c + 595230e commit ba62479
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/116922.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 116922
summary: Always check if index mode is logsdb
area: Logs
type: bug
issues: []
2 changes: 0 additions & 2 deletions docs/reference/search/retriever.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -704,5 +704,3 @@ Instead they are only allowed as elements of specific retrievers:
* <<search-after, `search_after`>>
* <<request-body-search-terminate-after, `terminate_after`>>
* <<search-sort-param, `sort`>>
* <<rescore, `rescore`>>

Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ public void process(IndexRequest indexRequest) {
// generate id if not already provided
final String id = indexRequest.id();
if (id == null) {
if (creationVersion.between(IndexVersions.TIME_BASED_K_ORDERED_DOC_ID_BACKPORT, IndexVersions.UPGRADE_TO_LUCENE_10_0_0)
|| creationVersion.onOrAfter(IndexVersions.TIME_BASED_K_ORDERED_DOC_ID) && indexMode == IndexMode.LOGSDB) {
if (shouldUseTimeBasedId(indexMode, creationVersion)) {
indexRequest.autoGenerateTimeBasedId();
} else {
indexRequest.autoGenerateId();
Expand All @@ -178,6 +177,15 @@ public void process(IndexRequest indexRequest) {
}
}

private static boolean shouldUseTimeBasedId(final IndexMode indexMode, final IndexVersion creationVersion) {
return indexMode == IndexMode.LOGSDB && isNewIndexVersion(creationVersion);
}

private static boolean isNewIndexVersion(final IndexVersion creationVersion) {
return creationVersion.between(IndexVersions.TIME_BASED_K_ORDERED_DOC_ID_BACKPORT, IndexVersions.UPGRADE_TO_LUCENE_10_0_0)
|| creationVersion.onOrAfter(IndexVersions.TIME_BASED_K_ORDERED_DOC_ID);
}

@Override
public int indexShard(
String id,
Expand Down

0 comments on commit ba62479

Please sign in to comment.