"filter" : [
{
"bool" : {
"must" : [
{
"script": {
"script": """
int day ;
int month ;
int year;
if ( (int) doc['decisionDate.decisionDay'].size() > 0 && (int) doc['decisionDate.decisionMonth'].size() > 0 && (int) doc['decisionDate.decisionYear'].size() > 0) {
day = (int) doc['decisionDate.decisionDay'].value;
month = (int) doc['decisionDate.decisionMonth'].value;
year = (int) doc['decisionDate.decisionYear'].value;
return
ChronoUnit.DAYS.between(ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZoneId.of('Z')),
ZonedDateTime.of(2022, 12, 13, 0, 0, 0, 0, ZoneId.of('Z'))) > 0 &&
ChronoUnit.DAYS.between(ZonedDateTime.of(2011, 03, 30, 0, 0, 0, 0, ZoneId.of('Z')),
ZonedDateTime.of( year, month, day, 0, 0, 0, 0, ZoneId.of('Z'))) > 0 ; } """
}
}
]
}
}
]
上面的代码是OpenSearch中的日期过滤器,带有日、月、年,我正在尝试将其转换为Java脚本。我不知道它是如何转换成Java的
尝试使用插件org.codelibs.fess:fess:14.4.0‘
final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final LabelTypeHelper labelTypeHelper = ComponentUtil.getLabelTypeHelper();
final LanguageHelper languageHelper = ComponentUtil.getLanguageHelper();
Script script = ComponentUtil.getLanguageHelper().createScript("here i need add the above (painless script), st);
1条答案
按热度按时间gijlo24d1#
这是在OpenSearch中存储的脚本
POST/_脚本/日期过滤器脚本{
}