Search in sources :

Example 1 with ESScriptResponse

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);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) ESScriptResponse(org.janusgraph.diskstorage.es.script.ESScriptResponse)

Aggregations

IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)1 ESScriptResponse (org.janusgraph.diskstorage.es.script.ESScriptResponse)1