use of org.janusgraph.diskstorage.es.script.ESScriptResponse in project janusgraph by JanusGraph.
the class ElasticSearchIndex method setupStoredScriptIfNeeded.
private void setupStoredScriptIfNeeded(String storedScriptId, String source) throws PermanentBackendException {
ImmutableMap<String, Object> preparedScript = compat.prepareScript(source).build();
String lang = (String) ((ImmutableMap<String, Object>) preparedScript.get(ES_SCRIPT_KEY)).get(ES_LANG_KEY);
try {
ESScriptResponse esScriptResponse = client.getStoredScript(storedScriptId);
if (Boolean.FALSE.equals(esScriptResponse.getFound()) || !Objects.equals(lang, esScriptResponse.getScript().getLang()) || !Objects.equals(source, esScriptResponse.getScript().getSource())) {
client.createStoredScript(storedScriptId, preparedScript);
}
} catch (final IOException e) {
throw new PermanentBackendException(e.getMessage(), e);
}
}
Aggregations