Files
OpenSearch-Docs-Cn/_opensearch/rest-api/_script-apis/get-script-contexts.md
T
Aria MarbleandSteve Murphy 21386b05d0 script api documentation (#1094)
* Add script documentation.

Signed-off-by: Steve Murphy <[email protected]>

* Use my own example script insteady of Elastic's.

Signed-off-by: Steve Murphy <[email protected]>

* edditing and format changes. verified API requests and scripts. various corrections

Signed-off-by: ariamarble <[email protected]>

* made a couple of suggested changes

Signed-off-by: ariamarble <[email protected]>

* made further corrections

Signed-off-by: ariamarble <[email protected]>

Signed-off-by: Steve Murphy <[email protected]>
Signed-off-by: ariamarble <[email protected]>
Co-authored-by: Steve Murphy <[email protected]>
2022-09-02 15:09:13 -07:00

12 KiB

layout, title, parent, grand_parent, nav_order
layout title parent grand_parent nav_order
default Get Stored Script Contexts Script APIs REST API reference 4

Get stored script contexts

Retrieves all contexts for stored scripts.

Sample request

GET _script_context

Sample response

The GET _script_context request returns the following fields:

{
  "contexts" : [
    {
      "name" : "aggregation_selector",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "aggs",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "get_score",
          "return_type" : "java.lang.Number",
          "params" : [ ]
        },
        {
          "name" : "get_value",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "aggs_combine",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getState",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "aggs_init",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "void",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getState",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "aggs_map",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "void",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getState",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "get_score",
          "return_type" : "double",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "aggs_reduce",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getStates",
          "return_type" : "java.util.List",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "analysis",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [
            {
              "type" : "org.opensearch.analysis.common.AnalysisPredicateScript$Token",
              "name" : "token"
            }
          ]
        }
      ]
    },
    {
      "name" : "bucket_aggregation",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Number",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "field",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "filter",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "ingest",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "void",
          "params" : [
            {
              "type" : "java.util.Map",
              "name" : "ctx"
            }
          ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "interval",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [
            {
              "type" : "org.opensearch.index.query.IntervalFilterScript$Interval",
              "name" : "interval"
            }
          ]
        }
      ]
    },
    {
      "name" : "moving-function",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [
            {
              "type" : "java.util.Map",
              "name" : "params"
            },
            {
              "type" : "double[]",
              "name" : "values"
            }
          ]
        }
      ]
    },
    {
      "name" : "number_sort",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "get_score",
          "return_type" : "double",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "painless_test",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Object",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "processor_conditional",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [
            {
              "type" : "java.util.Map",
              "name" : "ctx"
            }
          ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "score",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [
            {
              "type" : "org.opensearch.script.ScoreScript$ExplanationHolder",
              "name" : "explanation"
            }
          ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "get_score",
          "return_type" : "double",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "script_heuristic",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [
            {
              "type" : "java.util.Map",
              "name" : "params"
            }
          ]
        }
      ]
    },
    {
      "name" : "similarity",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [
            {
              "type" : "double",
              "name" : "weight"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Query",
              "name" : "query"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Field",
              "name" : "field"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Term",
              "name" : "term"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Doc",
              "name" : "doc"
            }
          ]
        }
      ]
    },
    {
      "name" : "similarity_weight",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "double",
          "params" : [
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Query",
              "name" : "query"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Field",
              "name" : "field"
            },
            {
              "type" : "org.opensearch.index.similarity.ScriptedSimilarity$Term",
              "name" : "term"
            }
          ]
        }
      ]
    },
    {
      "name" : "string_sort",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.String",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "get_score",
          "return_type" : "double",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "template",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.String",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "terms_set",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "java.lang.Number",
          "params" : [ ]
        },
        {
          "name" : "getDoc",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "trigger",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "boolean",
          "params" : [
            {
              "type" : "org.opensearch.alerting.script.QueryLevelTriggerExecutionContext",
              "name" : "ctx"
            }
          ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    },
    {
      "name" : "update",
      "methods" : [
        {
          "name" : "execute",
          "return_type" : "void",
          "params" : [ ]
        },
        {
          "name" : "getCtx",
          "return_type" : "java.util.Map",
          "params" : [ ]
        },
        {
          "name" : "getParams",
          "return_type" : "java.util.Map",
          "params" : [ ]
        }
      ]
    }
  ]
}

Response fields

The GET _scripts/my-first-script request returns the following response fields:

Field Data Type Description
contexts List A list of all contexts. See Script object.

Script context

Field Data Type Description
name String The context name.
methods List List of the context's allowable methods. See Script object.

Context methods

Field Data Type Description
name String Method name.
name String Type that the method returns (boolean, object, number, and so on).
params List List of the parameters accepted by the method. See Script object.

Method parameters

Field Data Type Description
type String Parameter data type.
name String Parameter name.