本文整理了Java中org.elasticsearch.script.Script.<init>()
方法的一些代码示例,展示了Script.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Script.<init>()
方法的具体详情如下:
包路径:org.elasticsearch.script.Script
类名称:Script
方法名:<init>
[英]For Serialization
[中]用于序列化
代码示例来源:origin: NLPchina/elasticsearch-sql
/**
* zhongshu-comment scripted_field only allows script(name,script) or script(name,lang,script)
* @param method
* @throws SqlParseException
*/
private void handleScriptField(MethodField method) throws SqlParseException {
List<KVValue> params = method.getParams();
if (params.size() == 2) {
String f = params.get(0).value.toString();
fieldNames.add(f);
request.addScriptField(f, new Script(params.get(1).value.toString()));
} else if (params.size() == 3) {
String f = params.get(0).value.toString();
fieldNames.add(f);
request.addScriptField(f,
new Script(
ScriptType.INLINE,
params.get(1).value.toString(),
params.get(2).value.toString(),
Collections.emptyMap()
)
);
} else {
throw new SqlParseException("scripted_field only allows script(name,script) or script(name,lang,script)");
}
}
代码示例来源:origin: NLPchina/elasticsearch-sql
scriptedMetricBuilder.mapScript(new Script(paramValue));
break;
case "map_script_id":
scriptedMetricBuilder.mapScript(new Script(ScriptType.STORED, Script.DEFAULT_SCRIPT_LANG,paramValue, new HashMap<String, Object>()));
break;
case "init_script":
scriptedMetricBuilder.initScript(new Script(paramValue));
break;
case "init_script_id":
scriptedMetricBuilder.initScript(new Script(ScriptType.STORED,Script.DEFAULT_SCRIPT_LANG,paramValue, new HashMap<String, Object>()));
break;
case "combine_script":
scriptedMetricBuilder.combineScript(new Script(paramValue));
break;
case "combine_script_id":
scriptedMetricBuilder.combineScript(new Script(ScriptType.STORED, Script.DEFAULT_SCRIPT_LANG,paramValue, new HashMap<String, Object>()));
break;
case "reduce_script":
scriptedMetricBuilder.reduceScript(new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG , paramValue, reduceScriptAdditionalParams));
break;
case "reduce_script_id":
scriptedMetricBuilder.reduceScript(new Script(ScriptType.STORED, Script.DEFAULT_SCRIPT_LANG,paramValue, reduceScriptAdditionalParams));
break;
case "alias":
代码示例来源:origin: alibaba/canal
.abortOnVersionConflict(false)
.filter(queryBuilder)
.script(new Script(ScriptType.INLINE, "painless", scriptLine, Collections.emptyMap()));
代码示例来源:origin: Graylog2/graylog2-server
.script(new Script(ScriptType.INLINE, "painless", scriptStringBuilder.toString(), Collections.emptyMap()))
.size(size > 0 ? size : 50)
.order(termsOrder));
代码示例来源:origin: NLPchina/elasticsearch-sql
if (kvValue.key != null && kvValue.key.equals("script")) {
if (kvValue.value instanceof MethodField) {
return builder.script(new Script(((MethodField) kvValue.value).getParams().get(1).toString()));
} else {
return builder.script(new Script(kvValue.value.toString()));
return builder.script(new Script(kvValue.value.toString()));
} else if (kvValue.key != null && (kvValue.key.equals("nested") || kvValue.key.equals("reverse_nested"))) {
NestedType nestedType = (NestedType) kvValue.value;
代码示例来源:origin: NLPchina/elasticsearch-sql
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
dateHistogram.script(new Script(script));
} else {
value = kv.value.toString();
代码示例来源:origin: NLPchina/elasticsearch-sql
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
histogram.script(new Script(script));
} else {
value = kv.value.toString();
代码示例来源:origin: NLPchina/elasticsearch-sql
TermsAggregationBuilder termsBuilder = AggregationBuilders.terms(methodField.getAlias()).script(new Script(methodField.getParams().get(1).value.toString()));
代码示例来源:origin: NLPchina/elasticsearch-sql
if(kv.value.toString().contains("doc[")) {
String script = kv.value + "; return " + kv.key;
terms.script(new Script(script));
} else {
value = kv.value.toString();
代码示例来源:origin: NLPchina/elasticsearch-sql
/**
* Add sorts to the elasticsearch query based on the 'ORDER BY' clause.
*
* @param orderBys
* list of Order object
*/
private void setSorts(List<Order> orderBys) {
for (Order order : orderBys) {
if (order.getNestedPath() != null) {
request.addSort(SortBuilders.fieldSort(order.getName()).order(SortOrder.valueOf(order.getType())).setNestedSort(new NestedSortBuilder(order.getNestedPath())));
} else if (order.getName().contains("script(")) { //zhongshu-comment 该分支是我后来加的,用于兼容order by case when那种情况
String scriptStr = order.getName().substring("script(".length(), order.getName().length() - 1);
Script script = new Script(scriptStr);
ScriptSortBuilder scriptSortBuilder = SortBuilders.scriptSort(script, order.getScriptSortType());
scriptSortBuilder = scriptSortBuilder.order(SortOrder.valueOf(order.getType()));
request.addSort(scriptSortBuilder);
} else {
request.addSort(
order.getName(),
SortOrder.valueOf(order.getType()));
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Read from a stream.
*/
public ScriptScoreFunctionBuilder(StreamInput in) throws IOException {
super(in);
script = new Script(in);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Sets a query used for filtering out suggested phrases (collation).
*/
public PhraseSuggestionBuilder collateQuery(String collateQuery) {
this.collateQuery = new Script(ScriptType.INLINE, "mustache", collateQuery, Collections.emptyMap());
return this;
}
代码示例来源:origin: NLPchina/elasticsearch-sql
x = QueryBuilders.scriptQuery(new Script(scriptCode));
params = scriptFilter.getArgs();
x = QueryBuilders.scriptQuery(new Script(scriptFilter.getScriptType(), Script.DEFAULT_SCRIPT_LANG,scriptFilter.getScript(), params));
break;
default:
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* The script to execute. Note, make sure not to send different script each
* times and instead use script params if possible with the same
* (automatically compiled) script.
*
* @deprecated Use {@link #script(Script)} instead
*/
@Deprecated
public UpdateRequest script(String script, ScriptType scriptType, @Nullable Map<String, Object> scriptParams) {
this.script = new Script(scriptType, Script.DEFAULT_SCRIPT_LANG, script, scriptParams);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Read from a stream.
*/
public ScriptField(StreamInput in) throws IOException {
fieldName = in.readString();
script = new Script(in);
ignoreFailure = in.readBoolean();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Read from a stream.
*/
@SuppressWarnings("unchecked")
public BucketSelectorPipelineAggregator(StreamInput in) throws IOException {
super(in);
script = new Script(in);
gapPolicy = GapPolicy.readFrom(in);
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
if (in.readBoolean()) {
script = new Script(in);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Read from a stream.
*/
@SuppressWarnings("unchecked")
public BucketScriptPipelineAggregator(StreamInput in) throws IOException {
super(in);
script = new Script(in);
formatter = in.readNamedWriteable(DocValueFormat.class);
gapPolicy = GapPolicy.readFrom(in);
bucketsPathsMap = (Map<String, String>) in.readGenericValue();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
public MovFnPipelineAggregator(StreamInput in) throws IOException {
super(in);
script = new Script(in);
formatter = in.readNamedWriteable(DocValueFormat.class);
gapPolicy = BucketHelpers.GapPolicy.readFrom(in);
bucketsPath = in.readString();
window = in.readInt();
}
代码示例来源: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;
}
}
内容来源于网络,如有侵权,请联系作者删除!