-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Search Pipelines] Support ad hoc pipelines (#7253)
* [Search Pipelines] Support ad hoc pipelines This change allows a search pipeline to be defined within a search request body. This will take precedence over any other search pipeline, and allows ad hoc testing of pipeline configurations before persisting the pipeline definition in cluster state. Signed-off-by: Michael Froh <[email protected]> * Added changelog entry Signed-off-by: Michael Froh <[email protected]> * Incorporate feedback from @reta Resolve + transform request into PipelinedRequest, then use that to transform the search response. Signed-off-by: Michael Froh <[email protected]> * Incorporate more feedback from @reta 1. Create all streams in try-with-resources. 2. Keep methods in Pipeline package-private. 3. Remove spurious character in CHANGELOG. Also, I remembered that in a future change, I'm going to call the no-op pipeline "_none" (like when bypassing an ingest pipeline) so I should name it "_none" from the start. Signed-off-by: Michael Froh <[email protected]> * Incorporate feedback from @andrross - Added opensearch.internal annotation to PipelinedRequest. - Made PipelinedRequest final. - Removed TODO from PipelinedRequest. - Moved changelog entry to 2.x. Signed-off-by: Michael Froh <[email protected]> --------- Signed-off-by: Michael Froh <[email protected]>
- Loading branch information
Showing
9 changed files
with
251 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
40 changes: 40 additions & 0 deletions
40
server/src/main/java/org/opensearch/search/pipeline/PipelinedRequest.java
This file contains 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,40 @@ | ||
/* | ||
* 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.search.pipeline; | ||
|
||
import org.opensearch.action.search.SearchRequest; | ||
import org.opensearch.action.search.SearchResponse; | ||
|
||
/** | ||
* Groups a search pipeline based on a request and the request after being transformed by the pipeline. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public final class PipelinedRequest { | ||
private final Pipeline pipeline; | ||
private final SearchRequest transformedRequest; | ||
|
||
PipelinedRequest(Pipeline pipeline, SearchRequest transformedRequest) { | ||
this.pipeline = pipeline; | ||
this.transformedRequest = transformedRequest; | ||
} | ||
|
||
public SearchResponse transformResponse(SearchResponse response) { | ||
return pipeline.transformResponse(transformedRequest, response); | ||
} | ||
|
||
public SearchRequest transformedRequest() { | ||
return transformedRequest; | ||
} | ||
|
||
// Visible for testing | ||
Pipeline getPipeline() { | ||
return pipeline; | ||
} | ||
} |
Oops, something went wrong.