Files
OpenSearch-Docs-Cn/_search-plugins/search-pipelines/script-processor.md
T
06527a2772 Add documentation about setting a default model for neural search (#5121)
* Add documentation about setting a default model for neural search

Signed-off-by: Fanit Kolchina <[email protected]>

* Add new processor to the processor list

Signed-off-by: Fanit Kolchina <[email protected]>

* More tweaks

Signed-off-by: Fanit Kolchina <[email protected]>

* Refactor search pipeline documentation

Signed-off-by: Fanit Kolchina <[email protected]>

* Refactor retrieving search pipelines

Signed-off-by: Fanit Kolchina <[email protected]>

* Add working examples

Signed-off-by: Fanit Kolchina <[email protected]>

* Implement tech review comments

Signed-off-by: Fanit Kolchina <[email protected]>

* Add responses to documentation

Signed-off-by: Fanit Kolchina <[email protected]>

* Update _search-plugins/search-pipelines/neural-query-enricher.md

Co-authored-by: Melissa Vagi <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Apply suggestions from code review

Co-authored-by: Nathan Bower <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Co-authored-by: Melissa Vagi <[email protected]>
Co-authored-by: Nathan Bower <[email protected]>
2023-10-04 13:35:37 -04:00

1.9 KiB

layout, title, nav_order, has_children, parent, grand_parent
layout title nav_order has_children parent grand_parent
default Script 30 false Search processors Search pipelines

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.

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 of this processor and continues to run the remaining processors in the search pipeline. Optional. Default is false.

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:

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 %}