-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Introduce system ingest pipeline. #17817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
saratvemulapalli
merged 2 commits into
opensearch-project:main
from
bzhangam:introduceIndexBasedIngestPipeline
May 9, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
server/src/main/java/org/opensearch/ingest/AbstractBatchingSystemProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.ingest; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Abstract base class for batch system generated processors. | ||
* | ||
* System processors should not be used in the regular ingest pipelines. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public abstract class AbstractBatchingSystemProcessor extends AbstractBatchingProcessor { | ||
protected AbstractBatchingSystemProcessor(String tag, String description, int batchSize) { | ||
super(tag, description, batchSize); | ||
} | ||
|
||
@Override | ||
public boolean isSystemGenerated() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Factory class for creating {@link AbstractBatchingSystemProcessor} instances systematically. | ||
* | ||
* Since the processor config is generated based on the index config so the batch size info should also be defined | ||
* as part of it. And different processors can have their own logic to decide the batch size so let each | ||
* implementation of the newProcessor to handle it. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public abstract static class Factory implements Processor.Factory { | ||
final String processorType; | ||
|
||
protected Factory(String processorType) { | ||
this.processorType = processorType; | ||
} | ||
|
||
@Override | ||
public boolean isSystemGenerated() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Creates a new processor instance. It will be invoked systematically. | ||
* | ||
* @param processorFactories The processor factories. | ||
* @param tag The processor tag. | ||
* @param description The processor description. | ||
* @param config The processor configuration. | ||
* @return The new AbstractBatchProcessor instance. | ||
* @throws Exception If the processor could not be created. | ||
*/ | ||
@Override | ||
public AbstractBatchingSystemProcessor create( | ||
Map<String, Processor.Factory> processorFactories, | ||
String tag, | ||
String description, | ||
Map<String, Object> config | ||
) throws Exception { | ||
return newProcessor(tag, description, config); | ||
} | ||
|
||
/** | ||
* Returns a new processor instance. It will be invoked systematically. | ||
* | ||
* @param tag tag of the processor | ||
* @param description description of the processor | ||
* @param config configuration of the processor | ||
* @return a new batch processor instance | ||
*/ | ||
protected abstract AbstractBatchingSystemProcessor newProcessor(String tag, String description, Map<String, Object> config); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
server/src/main/java/org/opensearch/ingest/IndexRequestWrapper.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.ingest; | ||
|
||
import org.opensearch.action.DocWriteRequest; | ||
import org.opensearch.action.index.IndexRequest; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A wrapper for the index request to help execute the ingest pipelines. | ||
*/ | ||
public class IndexRequestWrapper { | ||
/** | ||
* slot of the IndexRequestWrapper is the index of the request in the list of the requests. | ||
* It can be used to map the ingested result or exception to right index request. | ||
*/ | ||
private final int slot; | ||
private final IndexRequest indexRequest; | ||
private final DocWriteRequest<?> actionRequest; | ||
private final List<IngestPipelineInfo> pipelineInfoList; | ||
|
||
public IndexRequestWrapper( | ||
int slot, | ||
IndexRequest indexRequest, | ||
DocWriteRequest<?> actionRequest, | ||
List<IngestPipelineInfo> pipelineInfoList | ||
) { | ||
this.slot = slot; | ||
this.indexRequest = indexRequest; | ||
this.actionRequest = actionRequest; | ||
this.pipelineInfoList = pipelineInfoList; | ||
} | ||
|
||
public int getSlot() { | ||
return slot; | ||
} | ||
|
||
public IndexRequest getIndexRequest() { | ||
return indexRequest; | ||
} | ||
|
||
public DocWriteRequest<?> getActionRequest() { | ||
return actionRequest; | ||
} | ||
|
||
public List<IngestPipelineInfo> getIngestPipelineInfoList() { | ||
return pipelineInfoList; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
server/src/main/java/org/opensearch/ingest/IngestPipelineInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.ingest; | ||
|
||
import reactor.util.annotation.NonNull; | ||
|
||
/** | ||
* Ingest pipeline info help hold the pipeline id and type. | ||
*/ | ||
public class IngestPipelineInfo { | ||
private final String pipelineId; | ||
private final IngestPipelineType type; | ||
|
||
public IngestPipelineInfo(final @NonNull String pipelineId, final @NonNull IngestPipelineType type) { | ||
this.pipelineId = pipelineId; | ||
this.type = type; | ||
} | ||
|
||
public String getPipelineId() { | ||
return pipelineId; | ||
} | ||
|
||
public IngestPipelineType getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return pipelineId + ":" + type.name(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
server/src/main/java/org/opensearch/ingest/IngestPipelineType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.ingest; | ||
|
||
/** | ||
* An enum for the ingest pipeline type | ||
*/ | ||
public enum IngestPipelineType { | ||
/** | ||
* Default pipeline is the pipeline provided through the index request or defined in | ||
* the index settings as the default pipeline. | ||
*/ | ||
DEFAULT, | ||
/** | ||
* Final pipeline is the one defined in the index settings as the final pipeline. | ||
*/ | ||
FINAL, | ||
/** | ||
* System final pipeline is a systematically generated pipeline which will be executed after the | ||
* user defined final pipeline. | ||
*/ | ||
SYSTEM_FINAL | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.