Get Script Contexts API
Get Script Contexts API
1.0에서 도입
스크립트를 사용할 수 있는 모든 사용 가능한 컨텍스트(예: 검색, 업데이트, 집계 컨텍스트)를 조회해요.
출처: 문서
본문
예시 요청 (Example request)
GET /_script_context
Python 클라이언트로는 이렇게 호출해요:
response = client.get_script_context()
예시 응답 (Example response)
GET _script_context 요청은 다음 필드를 반환해요:
{
"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 body fields)
GET _script_context 요청은 다음 응답 필드를 반환해요.
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
contexts |
List | 모든 컨텍스트의 목록이에요. Script 컨텍스트를 참고해요. |
Script 컨텍스트
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
name |
String | 컨텍스트 이름이에요. |
methods |
List | 컨텍스트의 허용 메서드 목록이에요. Script 객체를 참고해요. |
컨텍스트 메서드 (Context methods)
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
name |
String | 메서드 이름이에요. |
return_type |
String | 메서드가 반환하는 타입이에요(boolean, object, number 등). |
params |
List | 메서드가 받는 매개변수 목록이에요. Script 객체를 참고해요. |
메서드 매개변수 (Method parameters)
| 필드 | 데이터 타입 | 설명 |
|---|---|---|
type |
String | 매개변수 데이터 타입이에요. |
name |
String | 매개변수 이름이에요. |