org.elasticsearch.common.Strings Java Examples
The following examples show how to use
org.elasticsearch.common.Strings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestIndicesExistsAction.java From Elasticsearch with Apache License 2.0 | 13 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(Strings.splitStringByCommaToArray(request.param("index"))); indicesExistsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesExistsRequest.indicesOptions())); indicesExistsRequest.local(request.paramAsBoolean("local", indicesExistsRequest.local())); client.admin().indices().exists(indicesExistsRequest, new RestResponseListener<IndicesExistsResponse>(channel) { @Override public RestResponse buildResponse(IndicesExistsResponse response) { if (response.isExists()) { return new BytesRestResponse(OK); } else { return new BytesRestResponse(NOT_FOUND); } } }); }
Example #2
Source File: DocumentParser.java From crate with Apache License 2.0 | 6 votes |
private static String[] splitAndValidatePath(String fullFieldPath) { if (fullFieldPath.contains(".")) { String[] parts = fullFieldPath.split("\\."); for (String part : parts) { if (Strings.hasText(part) == false) { // check if the field name contains only whitespace if (Strings.isEmpty(part) == false) { throw new IllegalArgumentException( "object field cannot contain only whitespace: ['" + fullFieldPath + "']"); } throw new IllegalArgumentException( "object field starting or ending with a [.] makes object resolution ambiguous: [" + fullFieldPath + "]"); } } return parts; } else { if (Strings.isEmpty(fullFieldPath)) { throw new IllegalArgumentException("field name cannot be an empty string"); } return new String[] {fullFieldPath}; } }
Example #3
Source File: RestSegmentsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); clusterStateRequest.clear().nodes(true).routingTable(true).indices(indices); client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { final IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest(); indicesSegmentsRequest.indices(indices); client.admin().indices().segments(indicesSegmentsRequest, new RestResponseListener<IndicesSegmentResponse>(channel) { @Override public RestResponse buildResponse(final IndicesSegmentResponse indicesSegmentResponse) throws Exception { final Map<String, IndexSegments> indicesSegments = indicesSegmentResponse.getIndices(); Table tab = buildTable(request, clusterStateResponse, indicesSegments); return RestTable.buildResponse(tab, channel); } }); } }); }
Example #4
Source File: CorsHandler.java From Elasticsearch with Apache License 2.0 | 6 votes |
private boolean validateOrigin() { if (config.isAnyOriginSupported()) { return true; } final String origin = request.headers().get(ORIGIN); if (Strings.isNullOrEmpty(origin)) { // Not a CORS request so we cannot validate it. It may be a non CORS request. return true; } if ("null".equals(origin) && config.isNullOriginAllowed()) { return true; } // if the origin is the same as the host of the request, then allow if (isSameOrigin(origin, request.headers().get(HOST))) { return true; } return config.isOriginAllowed(origin); }
Example #5
Source File: DiscoveryNode.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (nodeName.length() > 0) { sb.append('{').append(nodeName).append('}'); } if (nodeId != null) { sb.append('{').append(nodeId).append('}'); } if (Strings.hasLength(hostName)) { sb.append('{').append(hostName).append('}'); } if (address != null) { sb.append('{').append(address).append('}'); } if (!attributes.isEmpty()) { sb.append(attributes); } return sb.toString(); }
Example #6
Source File: MockAmazonS3.java From crate with Apache License 2.0 | 6 votes |
@Override public ObjectListing listObjects(final ListObjectsRequest request) throws AmazonClientException { assertThat(request.getBucketName(), equalTo(bucket)); final ObjectListing listing = new ObjectListing(); listing.setBucketName(request.getBucketName()); listing.setPrefix(request.getPrefix()); for (Map.Entry<String, byte[]> blob : blobs.entrySet()) { if (Strings.isEmpty(request.getPrefix()) || blob.getKey().startsWith(request.getPrefix())) { S3ObjectSummary summary = new S3ObjectSummary(); summary.setBucketName(request.getBucketName()); summary.setKey(blob.getKey()); summary.setSize(blob.getValue().length); listing.getObjectSummaries().add(summary); } } return listing; }
Example #7
Source File: ReplaceFunction.java From crate with Apache License 2.0 | 6 votes |
public static void register(ScalarFunctionModule module) { module.register( Signature.scalar( NAME, DataTypes.STRING.getTypeSignature(), DataTypes.STRING.getTypeSignature(), DataTypes.STRING.getTypeSignature(), DataTypes.STRING.getTypeSignature() ), (signature, boundSignature) -> new TripleScalar<>( signature, boundSignature, DataTypes.STRING, Strings::replace ) ); }
Example #8
Source File: RestShardsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); clusterStateRequest.clear().nodes(true).metaData(true).routingTable(true).indices(indices); client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(indices); indicesStatsRequest.all(); client.admin().indices().stats(indicesStatsRequest, new RestResponseListener<IndicesStatsResponse>(channel) { @Override public RestResponse buildResponse(IndicesStatsResponse indicesStatsResponse) throws Exception { return RestTable.buildResponse(buildTable(request, clusterStateResponse, indicesStatsResponse), channel); } }); } }); }
Example #9
Source File: IpFieldMapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException { IpFieldMapper.Builder builder = ipField(name); parseNumberField(builder, name, node, parserContext); for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) { Map.Entry<String, Object> entry = iterator.next(); String propName = Strings.toUnderscoreCase(entry.getKey()); Object propNode = entry.getValue(); if (propName.equals("null_value")) { if (propNode == null) { throw new MapperParsingException("Property [null_value] cannot be null."); } builder.nullValue(propNode.toString()); iterator.remove(); } } return builder; }
Example #10
Source File: AliasOrIndex.java From crate with Apache License 2.0 | 6 votes |
public void computeAndValidateWriteIndex() { List<IndexMetaData> writeIndices = referenceIndexMetaDatas.stream() .filter(idxMeta -> Boolean.TRUE.equals(idxMeta.getAliases().get(aliasName).writeIndex())) .collect(Collectors.toList()); if (writeIndices.isEmpty() && referenceIndexMetaDatas.size() == 1 && referenceIndexMetaDatas.get(0).getAliases().get(aliasName).writeIndex() == null) { writeIndices.add(referenceIndexMetaDatas.get(0)); } if (writeIndices.size() == 1) { writeIndex.set(writeIndices.get(0)); } else if (writeIndices.size() > 1) { List<String> writeIndicesStrings = writeIndices.stream() .map(i -> i.getIndex().getName()).collect(Collectors.toList()); throw new IllegalStateException("alias [" + aliasName + "] has more than one write index [" + Strings.collectionToCommaDelimitedString(writeIndicesStrings) + "]"); } }
Example #11
Source File: LangDetectProcessor.java From elasticsearch-ingest-langdetect with Apache License 2.0 | 6 votes |
@Override public IngestDocument execute(IngestDocument ingestDocument) throws Exception { Detector detector = DetectorFactory.create(); detector.setMaxTextLength(maxLength.bytesAsInt()); String content; try { content = ingestDocument.getFieldValue(field, String.class); } catch (IllegalArgumentException e) { if (ignoreMissing) { return ingestDocument; } throw e; } if (Strings.isEmpty(content)) { return ingestDocument; } detector.append(content); String language = detector.detect(); ingestDocument.setFieldValue(targetField, language); return ingestDocument; }
Example #12
Source File: PrometheusFetcherProvider.java From skywalking with Apache License 2.0 | 6 votes |
private void generateTraffic(MeterEntity entity) { ServiceTraffic s = new ServiceTraffic(); s.setName(requireNonNull(entity.getServiceName())); s.setNodeType(NodeType.Normal); s.setTimeBucket(TimeBucket.getMinuteTimeBucket(System.currentTimeMillis())); MetricsStreamProcessor.getInstance().in(s); if (!Strings.isNullOrEmpty(entity.getInstanceName())) { InstanceTraffic instanceTraffic = new InstanceTraffic(); instanceTraffic.setName(entity.getInstanceName()); instanceTraffic.setServiceId(entity.serviceId()); instanceTraffic.setTimeBucket(TimeBucket.getMinuteTimeBucket(System.currentTimeMillis())); instanceTraffic.setLastPingTimestamp(System.currentTimeMillis()); MetricsStreamProcessor.getInstance().in(instanceTraffic); } if (!Strings.isNullOrEmpty(entity.getEndpointName())) { EndpointTraffic endpointTraffic = new EndpointTraffic(); endpointTraffic.setName(entity.getEndpointName()); endpointTraffic.setServiceId(entity.serviceId()); endpointTraffic.setTimeBucket(TimeBucket.getMinuteTimeBucket(System.currentTimeMillis())); MetricsStreamProcessor.getInstance().in(endpointTraffic); } }
Example #13
Source File: TypeParsers.java From Elasticsearch with Apache License 2.0 | 6 votes |
public static void parseTermVector(String fieldName, String termVector, FieldMapper.Builder builder) throws MapperParsingException { termVector = Strings.toUnderscoreCase(termVector); if ("no".equals(termVector)) { builder.storeTermVectors(false); } else if ("yes".equals(termVector)) { builder.storeTermVectors(true); } else if ("with_offsets".equals(termVector)) { builder.storeTermVectorOffsets(true); } else if ("with_positions".equals(termVector)) { builder.storeTermVectorPositions(true); } else if ("with_positions_offsets".equals(termVector)) { builder.storeTermVectorPositions(true); builder.storeTermVectorOffsets(true); } else if ("with_positions_payloads".equals(termVector)) { builder.storeTermVectorPositions(true); builder.storeTermVectorPayloads(true); } else if ("with_positions_offsets_payloads".equals(termVector)) { builder.storeTermVectorPositions(true); builder.storeTermVectorOffsets(true); builder.storeTermVectorPayloads(true); } else { throw new MapperParsingException("wrong value for termVector [" + termVector + "] for field [" + fieldName + "]"); } }
Example #14
Source File: TransportClusterHealthAction.java From crate with Apache License 2.0 | 6 votes |
private ClusterHealthResponse clusterHealth(ClusterHealthRequest request, ClusterState clusterState, int numberOfPendingTasks, int numberOfInFlightFetch, TimeValue pendingTaskTimeInQueue) { if (logger.isTraceEnabled()) { logger.trace("Calculating health based on state version [{}]", clusterState.version()); } String[] concreteIndices; try { concreteIndices = indexNameExpressionResolver.concreteIndexNames(clusterState, request); } catch (IndexNotFoundException e) { // one of the specified indices is not there - treat it as RED. ClusterHealthResponse response = new ClusterHealthResponse(clusterState.getClusterName().value(), Strings.EMPTY_ARRAY, clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue); response.setStatus(ClusterHealthStatus.RED); return response; } return new ClusterHealthResponse(clusterState.getClusterName().value(), concreteIndices, clusterState, numberOfPendingTasks, numberOfInFlightFetch, UnassignedInfo.getNumberOfDelayedUnassigned(clusterState), pendingTaskTimeInQueue); }
Example #15
Source File: RestTermVectorsAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
static public void addFieldStringsFromParameter(TermVectorsRequest termVectorsRequest, String fields) { Set<String> selectedFields = termVectorsRequest.selectedFields(); if (fields != null) { String[] paramFieldStrings = Strings.commaDelimitedListToStringArray(fields); for (String field : paramFieldStrings) { if (selectedFields == null) { selectedFields = new HashSet<>(); } if (!selectedFields.contains(field)) { field = field.replaceAll("\\s", ""); selectedFields.add(field); } } } if (selectedFields != null) { termVectorsRequest.selectedFields(selectedFields.toArray(new String[selectedFields.size()])); } }
Example #16
Source File: ADStatsTests.java From anomaly-detection with Apache License 2.0 | 6 votes |
@Test public void testADStatsNodeResponse() throws IOException, JsonPathNotFoundException { Map<String, Object> stats = new HashMap<String, Object>() { { put("testKey", "testValue"); } }; // Test serialization ADStatsNodeResponse adStatsNodeResponse = new ADStatsNodeResponse(discoveryNode1, stats); BytesStreamOutput output = new BytesStreamOutput(); adStatsNodeResponse.writeTo(output); StreamInput streamInput = output.bytes().streamInput(); ADStatsNodeResponse readResponse = ADStatsNodeResponse.readStats(streamInput); assertEquals("readStats failed", readResponse.getStatsMap(), adStatsNodeResponse.getStatsMap()); // Test toXContent XContentBuilder builder = jsonBuilder(); adStatsNodeResponse.toXContent(builder.startObject(), ToXContent.EMPTY_PARAMS).endObject(); String json = Strings.toString(builder); for (Map.Entry<String, Object> stat : stats.entrySet()) { assertEquals("toXContent does not work", JsonDeserializer.getTextValue(json, stat.getKey()), stat.getValue()); } }
Example #17
Source File: Elasticsearch5Sink.java From sylph with Apache License 2.0 | 6 votes |
@Autowired public Elasticsearch5Sink(SinkContext context, ClientFactory clientFactory) { this.config = clientFactory.getConfig(); this.schema = context.getSchema(); this.clientFactory = clientFactory; if (!Strings.isNullOrEmpty(config.getIdField())) { int fieldIndex = schema.getFieldIndex(config.getIdField()); checkState(fieldIndex != -1, config.getIdField() + " does not exist, only " + schema.getFields()); this.idIndex = fieldIndex; } if (config.isUpdate()) { checkState(idIndex != -1, "This is Update mode, `id_field` must be set"); } }
Example #18
Source File: ArrayType.java From crate with Apache License 2.0 | 6 votes |
private String anyValueToString(Object value) { if (value == null) { return null; } try { if (value instanceof Map) { //noinspection unchecked return Strings.toString( XContentFactory.jsonBuilder().map((Map<String, ?>) value)); } else if (value instanceof Collection) { var array = XContentFactory.jsonBuilder().startArray(); for (var element : (Collection<?>) value) { array.value(element); } array.endArray(); return Strings.toString(array); } else { return value.toString(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #19
Source File: ClusterHealthRequest.java From crate with Apache License 2.0 | 6 votes |
public ClusterHealthRequest(StreamInput in) throws IOException { super(in); int size = in.readVInt(); if (size == 0) { indices = Strings.EMPTY_ARRAY; } else { indices = new String[size]; for (int i = 0; i < indices.length; i++) { indices[i] = in.readString(); } } timeout = in.readTimeValue(); if (in.readBoolean()) { waitForStatus = ClusterHealthStatus.fromValue(in.readByte()); } waitForNoRelocatingShards = in.readBoolean(); waitForActiveShards = ActiveShardCount.readFrom(in); waitForNodes = in.readString(); if (in.readBoolean()) { waitForEvents = Priority.readFrom(in); } waitForNoInitializingShards = in.readBoolean(); }
Example #20
Source File: SizeValue.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public String toString() { long singles = singles(); double value = singles; String suffix = ""; if (singles >= SizeUnit.C5) { value = petaFrac(); suffix = "p"; } else if (singles >= SizeUnit.C4) { value = teraFrac(); suffix = "t"; } else if (singles >= SizeUnit.C3) { value = gigaFrac(); suffix = "g"; } else if (singles >= SizeUnit.C2) { value = megaFrac(); suffix = "m"; } else if (singles >= SizeUnit.C1) { value = kiloFrac(); suffix = "k"; } return Strings.format1Decimals(value, suffix); }
Example #21
Source File: PropertyPlaceholder.java From Elasticsearch with Apache License 2.0 | 6 votes |
private int findPlaceholderEndIndex(CharSequence buf, int startIndex) { int index = startIndex + this.placeholderPrefix.length(); int withinNestedPlaceholder = 0; while (index < buf.length()) { if (Strings.substringMatch(buf, index, this.placeholderSuffix)) { if (withinNestedPlaceholder > 0) { withinNestedPlaceholder--; index = index + this.placeholderSuffix.length(); } else { return index; } } else if (Strings.substringMatch(buf, index, this.placeholderPrefix)) { withinNestedPlaceholder++; index = index + this.placeholderPrefix.length(); } else { index++; } } return -1; }
Example #22
Source File: Settings.java From crate with Apache License 2.0 | 6 votes |
/** * The values associated with a setting key as an immutable list. * <p> * It will also automatically load a comma separated list under the settingPrefix and merge with * the numbered format. * * @param key The setting key to load the list by * @param defaultValue The default value to use if no value is specified * @param commaDelimited Whether to try to parse a string as a comma-delimited value * @return The setting list values */ public List<String> getAsList(String key, List<String> defaultValue, Boolean commaDelimited) throws SettingsException { List<String> result = new ArrayList<>(); final Object valueFromPrefix = settings.get(key); if (valueFromPrefix != null) { if (valueFromPrefix instanceof List) { return Collections.unmodifiableList((List<String>) valueFromPrefix); } else if (commaDelimited) { String[] strings = Strings.splitStringByCommaToArray(get(key)); if (strings.length > 0) { for (String string : strings) { result.add(string.trim()); } } } else { result.add(get(key).trim()); } } if (result.isEmpty()) { return defaultValue; } return Collections.unmodifiableList(result); }
Example #23
Source File: Settings.java From Elasticsearch with Apache License 2.0 | 6 votes |
Settings(Map<String, String> settings) { // we use a sorted map for consistent serialization when using getAsMap() // TODO: use Collections.unmodifiableMap with a TreeMap this.settings = ImmutableSortedMap.copyOf(settings); Map<String, String> forcedUnderscoreSettings = null; for (Map.Entry<String, String> entry : settings.entrySet()) { String toUnderscoreCase = Strings.toUnderscoreCase(entry.getKey()); if (!toUnderscoreCase.equals(entry.getKey())) { if (forcedUnderscoreSettings == null) { forcedUnderscoreSettings = new HashMap<>(); } forcedUnderscoreSettings.put(toUnderscoreCase, entry.getValue()); } } this.forcedUnderscoreSettings = forcedUnderscoreSettings == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(forcedUnderscoreSettings); }
Example #24
Source File: MetaDataCreateIndexService.java From crate with Apache License 2.0 | 5 votes |
/** * Validate the name for an index or alias against some static rules. */ public static void validateIndexOrAliasName(String index, BiFunction<String, String, ? extends RuntimeException> exceptionCtor) { if (!Strings.validFileName(index)) { throw exceptionCtor.apply(index, "must not contain the following characters " + Strings.INVALID_FILENAME_CHARS); } if (index.contains("#")) { throw exceptionCtor.apply(index, "must not contain '#'"); } if (index.contains(":")) { DEPRECATION_LOGGER.deprecated("index or alias name [" + index + "] containing ':' is deprecated. CrateDB 4.x will read, " + "but not allow creation of new indices containing ':'"); } if (index.charAt(0) == '_' || index.charAt(0) == '-' || index.charAt(0) == '+') { throw exceptionCtor.apply(index, "must not start with '_', '-', or '+'"); } int byteCount = 0; try { byteCount = index.getBytes("UTF-8").length; } catch (UnsupportedEncodingException e) { // UTF-8 should always be supported, but rethrow this if it is not for some reason throw new ElasticsearchException("Unable to determine length of index name", e); } if (byteCount > MAX_INDEX_NAME_BYTES) { throw exceptionCtor.apply(index, "index name is too long, (" + byteCount + " > " + MAX_INDEX_NAME_BYTES + ")"); } if (index.equals(".") || index.equals("..")) { throw exceptionCtor.apply(index, "must not be '.' or '..'"); } }
Example #25
Source File: XContentMapValues.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns an array of string value from a node value. * * If the node represents an array the corresponding array of strings is returned. * Otherwise the node is treated as a comma-separated string. */ public static String[] nodeStringArrayValue(Object node) { if (isArray(node)) { List list = (List) node; String[] arr = new String[list.size()]; for (int i = 0; i < arr.length; i++) { arr[i] = nodeStringValue(list.get(i), null); } return arr; } else { return Strings.splitStringByCommaToArray(node.toString()); } }
Example #26
Source File: AuditMessage.java From deprecated-security-advanced-modules with Apache License 2.0 | 5 votes |
@Override public String toString() { try { return Strings.toString(JsonXContent.contentBuilder().map(getAsMap())); } catch (final IOException e) { throw ExceptionsHelper.convertToElastic(e); } }
Example #27
Source File: ReNounRelationshipAnnotator.java From baleen with Apache License 2.0 | 5 votes |
@Override public void doInitialize(UimaContext aContext) throws ResourceInitializationException { super.doInitialize(aContext); type = "ReNoun"; if (!Strings.isEmpty(factCollection)) { MongoDatabase db = mongoResource.getDB(); factsColl = db.getCollection(factCollection); } }
Example #28
Source File: PathTrie.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void insert(String path, T value) { String[] strings = Strings.splitStringToArray(path, separator); if (strings.length == 0) { rootValue = value; return; } int index = 0; // supports initial delimiter. if (strings.length > 0 && strings[0].isEmpty()) { index = 1; } root.insert(strings, index, value); }
Example #29
Source File: Lucene.java From crate with Apache License 2.0 | 5 votes |
public static Version parse(String toParse, Version defaultValue) { if (Strings.hasLength(toParse)) { try { return Version.parseLeniently(toParse); } catch (ParseException e) { // pass to default } } return defaultValue; }
Example #30
Source File: RestGetIndicesAliasesAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final String[] aliases = Strings.splitStringByCommaToArray(request.param("name")); ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest() .routingTable(false) .nodes(false) .indices(indices); clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) { @Override public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception { MetaData metaData = response.getState().metaData(); builder.startObject(); final boolean isAllAliasesRequested = isAllOrWildcard(aliases); for (IndexMetaData indexMetaData : metaData) { builder.startObject(indexMetaData.getIndex(), XContentBuilder.FieldCaseConversion.NONE); builder.startObject("aliases"); for (ObjectCursor<AliasMetaData> cursor : indexMetaData.getAliases().values()) { if (isAllAliasesRequested || Regex.simpleMatch(aliases, cursor.value.alias())) { AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS); } } builder.endObject(); builder.endObject(); } builder.endObject(); return new BytesRestResponse(OK, builder); } }); }