Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,10 @@ public IndexMetadata getIndexMetadata(String index)
// Older versions of ElasticSearch supported multiple "type" mappings
// for a given index. Newer versions support only one and don't
// expose it in the document. Here we skip it if it's present.

if (!mappings.elements().hasNext()) {
return new IndexMetadata(new IndexMetadata.ObjectType(ImmutableList.of()));
}
mappings = mappings.elements().next();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,4 +805,12 @@ private void createIndex(String indexName, @Language("JSON") String mapping)
client.getLowLevelClient()
.performRequest("PUT", "/" + indexName, ImmutableMap.of(), new NStringEntity(mapping, ContentType.APPLICATION_JSON));
}

@Test
public void testEmptyIndexNoMappings()
throws IOException
{
client.getLowLevelClient().performRequest("PUT", "/emptyindex");
assertQueryFails("SELECT * FROM emptyindex", "line 1:8: SELECT \\* not allowed from relation that has no columns");
}
}