parent
103059d9ef
commit
cd5ebac7dd
|
@ -236,9 +236,8 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
* Finds the specific index aliases that match with the specified aliases directly or partially via wildcards and
|
||||
* that point to the specified concrete indices or match partially with the indices via wildcards.
|
||||
*
|
||||
* @param aliases The names of the index aliases to find
|
||||
* @param aliases The names of the index aliases to find
|
||||
* @param concreteIndices The concrete indexes the index aliases must point to order to be returned.
|
||||
*
|
||||
* @return the found index aliases grouped by index
|
||||
*/
|
||||
public ImmutableMap<String, ImmutableList<AliasMetaData>> findAliases(final String[] aliases, String[] concreteIndices) {
|
||||
|
@ -255,8 +254,8 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
Collection<AliasMetaData> filteredValues = Maps.filterKeys(indexMetaData.getAliases(), new Predicate<String>() {
|
||||
|
||||
public boolean apply(String alias) {
|
||||
// Simon says: we could build and FST out of the alias key and then run a regexp query against it ;)
|
||||
return Regex.simpleMatch(aliases, alias);
|
||||
// Simon says: we could build and FST out of the alias key and then run a regexp query against it ;)
|
||||
return Regex.simpleMatch(aliases, alias);
|
||||
}
|
||||
|
||||
}).values();
|
||||
|
@ -271,9 +270,8 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
* Checks if at least one of the specified aliases exists in the specified concrete indices. Wildcards are supported in the
|
||||
* alias names for partial matches.
|
||||
*
|
||||
* @param aliases The names of the index aliases to find
|
||||
* @param aliases The names of the index aliases to find
|
||||
* @param concreteIndices The concrete indexes the index aliases must point to order to be returned.
|
||||
*
|
||||
* @return whether at least one of the specified aliases exists in one of the specified concrete indices.
|
||||
*/
|
||||
public boolean hasAliases(final String[] aliases, String[] concreteIndices) {
|
||||
|
@ -289,7 +287,7 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
Collection<AliasMetaData> filteredValues = Maps.filterKeys(indexMetaData.getAliases(), new Predicate<String>() {
|
||||
|
||||
public boolean apply(String alias) {
|
||||
return Regex.simpleMatch(aliases, alias);
|
||||
return Regex.simpleMatch(aliases, alias);
|
||||
}
|
||||
|
||||
}).values();
|
||||
|
@ -313,7 +311,8 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
IndexMetaData indexMetaData = indices.get(index);
|
||||
Map<String, MappingMetaData> filteredMappings;
|
||||
if (types.length == 0) {
|
||||
filteredMappings = indexMetaData.getMappings(); // No types specified means get it all
|
||||
indexMapBuilder.put(index, ImmutableMap.copyOf(indexMetaData.getMappings())); // No types specified means get it all
|
||||
|
||||
} else {
|
||||
filteredMappings = Maps.filterKeys(indexMetaData.getMappings(), new Predicate<String>() {
|
||||
|
||||
|
@ -323,9 +322,9 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
}
|
||||
|
||||
});
|
||||
}
|
||||
if (!filteredMappings.isEmpty()) {
|
||||
indexMapBuilder.put(index, ImmutableMap.copyOf(filteredMappings));
|
||||
if (!filteredMappings.isEmpty()) {
|
||||
indexMapBuilder.put(index, ImmutableMap.copyOf(filteredMappings));
|
||||
}
|
||||
}
|
||||
}
|
||||
return indexMapBuilder.build();
|
||||
|
@ -633,9 +632,9 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (actualIndices.isEmpty()) {
|
||||
throw new IndexMissingException(new Index(Arrays.toString(aliasesOrIndices)));
|
||||
throw new IndexMissingException(new Index(Arrays.toString(aliasesOrIndices)));
|
||||
}
|
||||
return actualIndices.toArray(new String[actualIndices.size()]);
|
||||
}
|
||||
|
@ -868,7 +867,7 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
* Identifies whether the first argument (an array containing index names) is a pattern that matches all indices
|
||||
*
|
||||
* @param indicesOrAliases the array containing index names
|
||||
* @param concreteIndices array containing the concrete indices that the first argument refers to
|
||||
* @param concreteIndices array containing the concrete indices that the first argument refers to
|
||||
* @return true if the first argument is a pattern that maps to all available indices, false otherwise
|
||||
*/
|
||||
public boolean isPatternMatchingAllIndices(String[] indicesOrAliases, String[] concreteIndices) {
|
||||
|
@ -897,8 +896,12 @@ public class MetaData implements Iterable<IndexMetaData> {
|
|||
}
|
||||
|
||||
public static boolean isGlobalStateEquals(MetaData metaData1, MetaData metaData2) {
|
||||
if (!metaData1.persistentSettings.equals(metaData2.persistentSettings)) return false;
|
||||
if (!metaData1.templates.equals(metaData2.templates())) return false;
|
||||
if (!metaData1.persistentSettings.equals(metaData2.persistentSettings)) {
|
||||
return false;
|
||||
}
|
||||
if (!metaData1.templates.equals(metaData2.templates())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,21 @@ import org.elasticsearch.test.integration.AbstractSharedClusterTest;
|
|||
import org.junit.Test;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SimpleGetMappingsTests extends AbstractSharedClusterTest {
|
||||
|
||||
@Test
|
||||
public void getMappingsWhereThereAreNone() {
|
||||
createIndex("index");
|
||||
GetMappingsResponse response = client().admin().indices().prepareGetMappings().execute().actionGet();
|
||||
assertThat(response.mappings(), hasKey("index"));
|
||||
assertThat(response.mappings().get("index").size(), equalTo(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleGetMappings() throws Exception {
|
||||
XContentBuilder mapping = jsonBuilder().startObject().startObject("properties")
|
||||
|
|
Loading…
Reference in New Issue