opensearch-docs-cn/_search-plugins/search-pipelines/script-processor.md

58 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

Add search pipeline documentation (#4204) * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add experimental label Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update script processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and pipeline path parameter Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded get pipeline responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add we do not recommend to use the feature in prod Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Add header to table Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented tech review and editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-06-06 11:11:52 -04:00
---
layout: default
Add score normalization and combination documentation (#4985) * Add search phase results processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add hybrid query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Normalization processor additions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add more details Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Continue writing Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add more query then fetch details and diagram Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewording Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Leaner left nav headers Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Tech review feedback Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add semantic search tutorial Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded prerequisites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Removed comma Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewording advanced prerequisites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Changed searching for ML model to shorter request Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update task type in register model response Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Changing example Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added huggingface prefix to model names Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change example responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added note about huggingface prefix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update _ml-commons-plugin/semantic-search.md Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented doc review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * List weights under parameters Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Remove one-shard warning for normalization processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change links Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More editorial feedback Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change model-serving framework to ML framework Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Use get model API to check model status Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added neural search description and diagram Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add link to profile API Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Addressed more tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented editorial comments on changes Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-09-22 17:29:58 -04:00
title: Script
Add search pipeline documentation (#4204) * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add experimental label Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update script processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and pipeline path parameter Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded get pipeline responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add we do not recommend to use the feature in prod Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Add header to table Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented tech review and editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-06-06 11:11:52 -04:00
nav_order: 30
has_children: false
parent: Search processors
grand_parent: Search pipelines
Add search pipeline documentation (#4204) * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add experimental label Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update script processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and pipeline path parameter Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded get pipeline responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add we do not recommend to use the feature in prod Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Add header to table Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented tech review and editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-06-06 11:11:52 -04:00
---
# Script processor
The `script` search request processor intercepts a search request and adds an inline Painless script that is run on incoming requests. The script can only run on the following request fields:
- `from`
- `size`
- `explain`
- `version`
- `seq_no_primary_term`
- `track_scores`
- `track_total_hits`
- `min_score`
- `terminate_after`
- `profile`
For request field definitions, see [search request fields]({{site.url}}{{site.baseurl}}/api-reference/search#request-body).
## Request fields
The following table lists all available request fields.
Field | Data type | Description
:--- | :--- | :---
`source` | Inline script | The script to run. Required.
`lang` | String | The script language. Optional. Only `painless` is supported.
`tag` | String | The processor's identifier. Optional.
`description` | String | A description of the processor. Optional.
`ignore_failure` | Boolean | If `true`, OpenSearch [ignores any failure]({{site.url}}{{site.baseurl}}/search-plugins/search-pipelines/creating-search-pipeline/#ignoring-processor-failures) of this processor and continues to run the remaining processors in the search pipeline. Optional. Default is `false`.
Add search pipeline documentation (#4204) * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add search pipeline documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add experimental label Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update script processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and pipeline path parameter Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded get pipeline responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add we do not recommend to use the feature in prod Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Add header to table Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented tech review and editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-06-06 11:11:52 -04:00
## Example
The following request creates a search pipeline with a `script` request processor. The script limits score explanation to only one document because `explain` is an expensive operation:
```json
PUT /_search/pipeline/explain_one_result
{
"description": "A pipeline to limit the explain operation to one result only",
"request_processors": [
{
"script": {
"lang": "painless",
"source": "if (ctx._source['size'] > 1) { ctx._source['explain'] = false } else { ctx._source['explain'] = true }"
}
}
]
}
```
{% include copy-curl.html %}