本文整理了Java中org.elasticsearch.script.Script.getParams()
方法的一些代码示例,展示了Script.getParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Script.getParams()
方法的具体详情如下:
包路径:org.elasticsearch.script.Script
类名称:Script
方法名:getParams
[英]Method for getting the parameters.
[中]获取参数的方法。
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* @deprecated Use {@link #script()} instead
*/
@Deprecated
public Map<String, Object> scriptParams() {
return this.script == null ? null : this.script.getParams();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
ExecutableScriptHeuristic(Script script, SignificantTermsHeuristicScoreScript executableScript) {
super(script);
subsetSizeHolder = new LongAccessor();
supersetSizeHolder = new LongAccessor();
subsetDfHolder = new LongAccessor();
supersetDfHolder = new LongAccessor();
this.executableScript = executableScript;
params.putAll(script.getParams());
params.put("_subset_freq", subsetDfHolder);
params.put("_subset_size", subsetSizeHolder);
params.put("_superset_freq", supersetDfHolder);
params.put("_superset_size", supersetSizeHolder);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private Map<String, Object> executeScript(Script script, Map<String, Object> ctx) {
try {
if (scriptService != null) {
UpdateScript.Factory factory = scriptService.compile(script, UpdateScript.CONTEXT);
UpdateScript executableScript = factory.newInstance(script.getParams(), ctx);
executableScript.execute();
}
} catch (Exception e) {
throw new IllegalArgumentException("failed to execute script", e);
}
return ctx;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Add a script parameter.
*
* @deprecated Use {@link #script(Script)} instead
*/
@Deprecated
public UpdateRequest addScriptParam(String name, Object value) {
Script script = script();
if (script == null) {
HashMap<String, Object> scriptParams = new HashMap<>();
scriptParams.put(name, value);
updateOrCreateScript(null, null, null, scriptParams);
} else {
Map<String, Object> scriptParams = script.getParams();
if (scriptParams == null) {
scriptParams = new HashMap<>();
scriptParams.put(name, value);
updateOrCreateScript(null, null, null, scriptParams);
} else {
scriptParams.put(name, value);
}
}
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public InternalAggregation reduce(InternalAggregation aggregation, ReduceContext reduceContext) {
InternalMultiBucketAggregation<InternalMultiBucketAggregation, InternalMultiBucketAggregation.InternalBucket> originalAgg =
(InternalMultiBucketAggregation<InternalMultiBucketAggregation, InternalMultiBucketAggregation.InternalBucket>) aggregation;
List<? extends InternalMultiBucketAggregation.InternalBucket> buckets = originalAgg.getBuckets();
BucketAggregationSelectorScript.Factory factory =
reduceContext.scriptService().compile(script, BucketAggregationSelectorScript.CONTEXT);
List<InternalMultiBucketAggregation.InternalBucket> newBuckets = new ArrayList<>();
for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) {
Map<String, Object> vars = new HashMap<>();
if (script.getParams() != null) {
vars.putAll(script.getParams());
}
for (Map.Entry<String, String> entry : bucketsPathsMap.entrySet()) {
String varName = entry.getKey();
String bucketsPath = entry.getValue();
Double value = resolveBucketValue(originalAgg, bucket, bucketsPath, gapPolicy);
vars.put(varName, value);
}
// TODO: can we use one instance of the script for all buckets? it should be stateless?
BucketAggregationSelectorScript executableScript = factory.newInstance(vars);
if (executableScript.execute()) {
newBuckets.add(bucket);
}
}
return originalAgg.create(newBuckets);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
for (InternalMultiBucketAggregation.InternalBucket bucket : buckets) {
Map<String, Object> vars = new HashMap<>();
if (script.getParams() != null) {
vars.putAll(script.getParams());
代码示例来源:origin: org.elasticsearch/elasticsearch
private static SearchScript.LeafFactory createScript(Script script, QueryShardContext context) {
if (script == null) {
return null;
} else {
SearchScript.Factory factory = context.getScriptService().compile(script, SearchScript.AGGS_CONTEXT);
return factory.newFactory(script.getParams(), context.lookup());
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (firstAggregation.reduceScript != null && reduceContext.isFinalReduce()) {
Map<String, Object> params = new HashMap<>();
if (firstAggregation.reduceScript.getParams() != null) {
params.putAll(firstAggregation.reduceScript.getParams());
代码示例来源:origin: org.elasticsearch/elasticsearch
private LongValuesSource createValuesSource(QueryShardContext context) {
LongValuesSource longValuesSource;
if (minimumShouldMatchField != null) {
MappedFieldType msmFieldType = context.fieldMapper(minimumShouldMatchField);
if (msmFieldType == null) {
throw new QueryShardException(context, "failed to find minimum_should_match field [" + minimumShouldMatchField + "]");
}
IndexNumericFieldData fieldData = context.getForField(msmFieldType);
longValuesSource = new FieldValuesSource(fieldData);
} else if (minimumShouldMatchScript != null) {
TermsSetQueryScript.Factory factory = context.getScriptService().compile(minimumShouldMatchScript,
TermsSetQueryScript.CONTEXT);
Map<String, Object> params = new HashMap<>();
params.putAll(minimumShouldMatchScript.getParams());
params.put("num_terms", values.size());
longValuesSource = new ScriptLongValueSource(minimumShouldMatchScript, factory.newFactory(params, context.lookup()));
} else {
throw new IllegalStateException("No minimum should match has been specified");
}
return longValuesSource;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public Explanation explainScore(int docId, Explanation subQueryScore) throws IOException {
Explanation exp;
if (leafScript instanceof ExplainableSearchScript) {
leafScript.setDocument(docId);
scorer.docid = docId;
scorer.score = subQueryScore.getValue();
exp = ((ExplainableSearchScript) leafScript).explain(subQueryScore);
} else {
double score = score(docId, subQueryScore.getValue());
String explanation = "script score function, computed with script:\"" + sScript + "\"";
if (sScript.getParams() != null) {
explanation += " and parameters: \n" + sScript.getParams().toString();
}
Explanation scoreExp = Explanation.match(
subQueryScore.getValue(), "_score: ",
subQueryScore);
return Explanation.match(
(float) score, explanation,
scoreExp);
}
return exp;
}
};
代码示例来源:origin: org.elasticsearch/elasticsearch
private static Script deepCopyScript(Script script, SearchContext context) {
if (script != null) {
Map<String, Object> params = script.getParams();
if (params != null) {
params = deepCopyParams(params, context);
}
return new Script(script.getType(), script.getLang(), script.getIdOrCode(), params);
} else {
return null;
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
boolean evaluate(IngestDocument ingestDocument) {
IngestConditionalScript script =
scriptService.compile(condition, IngestConditionalScript.CONTEXT).newInstance(condition.getParams());
return script.execute(new UnmodifiableIngestData(ingestDocument.getSourceAndMetadata()));
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
FilterScript.Factory factory = context.getScriptService().compile(script, FilterScript.CONTEXT);
FilterScript.LeafFactory filterScript = factory.newFactory(script.getParams(), context.lookup());
return new ScriptQuery(script, filterScript);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (initScript != null) {
compiledInitScript = queryShardContext.getScriptService().compile(initScript, ScriptedMetricAggContexts.InitScript.CONTEXT);
initScriptParams = initScript.getParams();
} else {
compiledInitScript = (p, a) -> null;
Map<String, Object> mapScriptParams = mapScript.getParams();
compiledCombineScript = queryShardContext.getScriptService().compile(combineScript,
ScriptedMetricAggContexts.CombineScript.CONTEXT);
combineScriptParams = combineScript.getParams();
} else {
compiledCombineScript = (p, a) -> null;
代码示例来源:origin: org.elasticsearch/elasticsearch
if (script.getParams() != null) {
vars.putAll(script.getParams());
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
protected ScoreFunction doToFunction(QueryShardContext context) {
try {
ScoreScript.Factory factory = context.getScriptService().compile(script, ScoreScript.CONTEXT);
ScoreScript.LeafFactory searchScript = factory.newFactory(script.getParams(), context.lookup());
return new ScriptScoreFunction(script, searchScript);
} catch (Exception e) {
throw new QueryShardException(context, "script_score: the script could not be loaded", e);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private void updateOrCreateScript(String scriptContent, ScriptType type, String lang, Map<String, Object> params) {
Script script = script();
if (script == null) {
script = new Script(type == null ? ScriptType.INLINE : type, lang, scriptContent == null ? "" : scriptContent, params);
} else {
String newScriptContent = scriptContent == null ? script.getIdOrCode() : scriptContent;
ScriptType newScriptType = type == null ? script.getType() : type;
String newScriptLang = lang == null ? script.getLang() : lang;
Map<String, Object> newScriptParams = params == null ? script.getParams() : params;
script = new Script(newScriptType, newScriptLang, newScriptContent, newScriptParams);
}
script(script);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
QueryShardContext shardContext = context.getQueryShardContext();
SearchScript.Factory factory = shardContext.getScriptService().compile(field.script(), SearchScript.CONTEXT);
SearchScript.LeafFactory searchScript = factory.newFactory(field.script().getParams(), shardContext.lookup());
fields.add(new org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField(
field.fieldName(), searchScript, field.ignoreFailure()));
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public SortFieldAndFormat build(QueryShardContext context) throws IOException {
final SearchScript.Factory factory = context.getScriptService().compile(script, SearchScript.SCRIPT_SORT_CONTEXT);
final SearchScript.LeafFactory searchScript = factory.newFactory(script.getParams(), context.lookup());
代码示例来源:origin: org.elasticsearch/elasticsearch
QueryShardContext innerContext = innerHitsContext.getQueryShardContext();
SearchScript.Factory factory = innerContext.getScriptService().compile(field.script(), SearchScript.CONTEXT);
SearchScript.LeafFactory searchScript = factory.newFactory(field.script().getParams(), innerHitsContext.lookup());
innerHitsContext.scriptFields().add(new org.elasticsearch.search.fetch.subphase.ScriptFieldsContext.ScriptField(
field.fieldName(), searchScript, field.ignoreFailure()));
内容来源于网络,如有侵权,请联系作者删除!