elasticSearch script api

Package org.elasticsearch.script

Support for running user provided scripts (in the request, in cluster state, etc) in portions of various requests (FunctionScoreQueryAggregationUpdateAction, etc).
Interface Summary
InterfaceDescription
ExecutableScript
An executable script, can't be used concurrently.
ExplainableSearchScript
To be implemented by SearchScript which can provided an Explanation of the score This is currently not used inside elasticsearch but it is used, see for example here: https://github.com/elastic/elasticsearch/issues/8561
LeafSearchScript
A per-segment SearchScript.
NativeScriptFactory Deprecated
Create a ScriptEngineService instead of using native scripts
ScriptContext
Context of an operation that uses scripts as part of its execution.
ScriptEngineService  
SearchScript
A search script.
Class Summary
ClassDescription
AbstractDoubleSearchScript
A simpler base class instead of AbstractSearchScript for computations that return a double number.
AbstractExecutableScript
AbstractLongSearchScript
A simpler base class instead of AbstractSearchScript for computations that return a long number.
AbstractSearchScript
A base class for any script type that is used during the search process (custom score, aggs, and so on).
ClassPermission
Checked by scripting engines to allow loading a java class.
CompiledScript
CompiledScript holds all the parameters necessary to execute a previously compiled script.
NativeScriptEngineService
A native script engine service.
ScoreAccessor
A float encapsulation that dynamically accesses the score of a document.
Script
Script represents used-defined input that can be used to compile and execute a script from the ScriptService based on the ScriptType.
ScriptContext.Plugin
Custom operation exposed via plugin, which makes use of scripts as part of its execution
ScriptContextRegistry
Registry for operations that use scripts as part of their execution.
ScriptEngineRegistry
ScriptMetaData
ScriptMetaData is used to store user-defined scripts as part of the ClusterState.
ScriptMetaData.Builder
A builder used to modify the currently stored scripts data held within the ClusterState.
ScriptMetrics
ScriptModes
Holds the boolean indicating the enabled mode for each of the different scripting languages available, each script source and each scripted operation.
ScriptModule
Manages building ScriptService and ScriptSettings from a list of plugins.
ScriptService
ScriptSettings
ScriptStats
StoredScriptSource
StoredScriptSource represents user-defined parameters for a script saved in the ClusterState.
Enum Summary
EnumDescription
ScriptContext.Standard
Standard operations that make use of scripts as part of their execution.
ScriptType
ScriptType represents the way a script is stored and retrieved from the ScriptService.

            

ScriptEnginService compile?..... 不推荐。

XXXPlugin extends Plugin implements ScriptPlugin

  实现方法: List<NativeScriptFactory> getNativeScripts()

实现XXXScriptFactory implements NativeScriptFactory  

                NativeScriptFactory  创建ExcutableScript实例 ( ExecutableScript newScript() )

    主要实现ExecutableScript newScript()

实现 XXXScript extends AbstractDoubleSearchScript 

            ExecutableScript( run())

    实现 runAsDouble()方法

ExecutableScript是接口。

AbsractSearchScritp 实现了ExecutableScript接口。

  AbsractSearchScritp 有个lookup!

NativeScriptEngineService

   search()会调用 script.setLookup()

依赖

ScriptService 的search(SearchLookup lookup)

依赖

parseSource(DefaultSearchContext context

 SearchScript searchScript = scriptService.search(context.lookup()

依赖 createAndPutContext

依赖executeDfsPhase

原文地址:https://www.cnblogs.com/ydxblog/p/7794542.html