private void updateIndexRefresh(String name, Object value) { esClient.admin().indices().prepareUpdateSettings(name).setSettings(ImmutableMap.of("index.refresh_interval", value)).get(); }
try { ExecutableScript executableScript = scriptService.executable(definition.getScriptType(), definition.getScript(), ScriptService.ScriptType.INLINE, ImmutableMap.<String, Object>of("logger", logger)); if (logger.isTraceEnabled()) { logger.trace("Script to be executed: {} - {}", definition.getScriptType(), definition.getScript());
ScriptService.ScriptType.INLINE, ImmutableMap.<String, Object>of("logger", logger)); executableScript.setNextVar("ctx", ctx); executableScript.run();
public ImmutableMap<String, BlobMetaData> listBlobs() throws IOException { FileStatus[] files = blobStore.fileSystem().listStatus(path); if (files == null || files.length == 0) { return ImmutableMap.of(); } ImmutableMap.Builder<String, BlobMetaData> builder = ImmutableMap.builder(); for (FileStatus file : files) { builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen())); } return builder.build(); }
@Override public ImmutableMap<String, BlobMetaData> listBlobsByPrefix(final String blobNamePrefix) throws IOException { FileStatus[] files = blobStore.fileSystem().listStatus(path, new PathFilter() { @Override public boolean accept(Path path) { return path.getName().startsWith(blobNamePrefix); } }); if (files == null || files.length == 0) { return ImmutableMap.of(); } ImmutableMap.Builder<String, BlobMetaData> builder = ImmutableMap.builder(); for (FileStatus file : files) { builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen())); } return builder.build(); }
@Override public GetResponse fromXContent(final Map<String, Object> map) { final Map<String, GetField> fields; if (map.containsKey("fields")) { Map<String, Object> incoming = nodeMapValue(map.get("fields"), String.class, Object.class); fields = Maps.newHashMapWithExpectedSize(incoming.size()); for (Map.Entry<String, Object> entry : incoming.entrySet()) { if (entry.getValue() instanceof List) { fields.put(entry.getKey(), new GetField(entry.getKey(), nodeListValue(entry.getValue(), Object.class))); } else { fields.put(entry.getKey(), new GetField(entry.getKey(), ImmutableList.of(entry.getValue()))); } } } else { fields = ImmutableMap.of(); } return new GetResponse(new GetResult( nodeStringValue(map.get("_index")), nodeStringValue(map.get("_type")), nodeStringValue(map.get("_id")), nodeLongValue(map.get("_version"), -1), nodeBooleanValue(map.get("found"), true), nodeBytesReferenceValue(map.get("_source")), fields )); } }
@Override public GetResponse fromXContent(final Map<String, Object> map) { final Map<String, GetField> fields; if (map.containsKey("fields")) { Map<String, Object> incoming = nodeMapValue(map.get("fields"), String.class, Object.class); fields = Maps.newHashMapWithExpectedSize(incoming.size()); for (Map.Entry<String, Object> entry : incoming.entrySet()) { if (entry.getValue() instanceof List) { fields.put(entry.getKey(), new GetField(entry.getKey(), nodeListValue(entry.getValue(), Object.class))); } else { fields.put(entry.getKey(), new GetField(entry.getKey(), ImmutableList.of(entry.getValue()))); } } } else { fields = ImmutableMap.of(); } //noinspection unchecked return new GetResponse(new GetResult( nodeStringValue(map.get("_index")), nodeStringValue(map.get("_type")), nodeStringValue(map.get("_id")), nodeLongValue(map.get("_version"), -1), nodeBooleanValue(map.get("found"), true), nodeBytesReferenceForMapValue((Map<String, ?>) map.get("_source")), fields )); } }
private void executeSearch(SearchContext context, QueryAndSource queryAndSource) { parseHighlighting(context, queryAndSource.getSource()); context.parsedQuery(new ParsedQuery(queryAndSource.getQuery(), ImmutableMap.<String, Filter>of())); if (context.from() == -1) { context.from(0); } if (context.size() == -1) { context.size(Integer.MAX_VALUE); } queryPhase.preProcess(context); fetchPhase.preProcess(context); queryPhase.execute(context); setDocIdsToLoad(context); fetchPhase.execute(context); }