我可以在ES 2.4上使用API批量创建新索引吗?
我首先尝试使用方法PrepareIndex
的官方文档中的示例,但它不会添加新索引。
另一方面,当我使用Administrative API时,它解决了问题,因此我可以创建这个索引。
public static void main(String[] args) throws IOException
{
XContentBuilder builder = jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elasticsearch")
.endObject();
TransportClient client = null;
try {
client = TransportClient.builder().build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
} catch (UnknownHostException e) {
System.out.println("Connection Tcp non valid : machine non reconnu ");
}
BulkRequestBuilder bulkRequest = client.prepareBulk();
bulkRequest.add(client.prepareIndex("flux","flux1","1").setSource(builder));
builder.flush();
client.close();
答案 0 :(得分:0)
您的弹性搜索实例可能具有阻止自动创建索引的设置,这意味着如果您将文档发布到非现有索引,则不会创建它。在action.auto_create_index
/etc/elasticsearch/elasticsearch.yml
属性
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-creation