[英]Elasticsearch Java API from 2.x to 5.x issues
I've updated to elasticsearch java library version 5.2.0. 我已经更新到Elasticsearch Java库版本5.2.0。
In 2.x, 在2.x版本中,
SearchRequestBuilder.addField()
in order to add a field to the search request. SearchRequestBuilder.addField()
以便向搜索请求中添加一个字段。 Nevertheless, It seems to be replaced. addDocValueField
addFieldDataField
addScriptField
addStoredField
storedFields
fields
SearchRequestBuilder.setNoFields
is also removed. SearchRequestBuilder.setNoFields
也将被删除。 Which would be the alternative? Code: 码:
return AggregationBuilders
.terms(this.getName())
.field(this.getName())
.script(new Script(
ScriptType.FILE,
"painless",
"year",
ImmutableMap.of("field", this.getName())
)
);
As you can see I setting field
as script parameter. 如您所见,我将
field
设置为脚本参数。 Nevertheless, I don't quite understand how to get it from script code. 但是,我不太了解如何从脚本代码中获取它。
Thanks. 谢谢。
When in doubt, go to the source 如有疑问, 请转至来源
setFetchSource(String[] includes, String[] excludes)
instead setFetchSource(String[] includes, String[] excludes)
setFetchSource(false)
instead setFetchSource(false)
代替 addScriptField()
addScriptField()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.