mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Native scripts should be created once per index, not per segment. (#20609)
If your native script needs to do some heavy computation on initialization, the fact that we create a new one for every segment rather than for the whole index could have a negative performance impact.
This commit is contained in:
parent
6705c6aa2f
commit
45469a5570
@ -72,10 +72,10 @@ public class NativeScriptEngineService extends AbstractComponent implements Scri
|
||||
@Override
|
||||
public SearchScript search(CompiledScript compiledScript, final SearchLookup lookup, @Nullable final Map<String, Object> vars) {
|
||||
final NativeScriptFactory scriptFactory = (NativeScriptFactory) compiledScript.compiled();
|
||||
final AbstractSearchScript script = (AbstractSearchScript) scriptFactory.newScript(vars);
|
||||
return new SearchScript() {
|
||||
@Override
|
||||
public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException {
|
||||
AbstractSearchScript script = (AbstractSearchScript) scriptFactory.newScript(vars);
|
||||
script.setLookup(lookup.getLeafSearchLookup(context));
|
||||
return script;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user