Hi,
I worte a java client to insert indexes into elasticsearch.
After succsufuly doing it i wanted to ad a new index with mapping.
where i ran into problem
Exception in thread "main" MapperParsingException[Failed to parse mapping [call]: Root mapping definition has unsupported parameters: [number : {type=long}]]; nested: MapperParsingException[Root mapping definition has unsupported parameters: [number : {type=long}]];
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:254)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:357)
at org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:45)
at org.elasticsearch.cluster.service.ClusterService.runTasksForExecutor(ClusterService.java:581)
at org.elasticsearch.cluster.service.ClusterService$UpdateTask.run(ClusterService.java:920)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:458)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:238)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:201)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: MapperParsingException[Root mapping definition has unsupported parameters: [number : {type=long}]]
at org.elasticsearch.index.mapper.DocumentMapperParser.checkNoRemainingFields(DocumentMapperParser.java:145)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:134)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:90)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:517)
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:282)
at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:252)
... 10 more
my code is very simple and i a POC
Settings settings = Settings.builder() .put("cluster.name", "sharongur").build();
Client client = new PreBuiltTransportClient(settings) .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("127.0.0.1"), 9300)); IndicesAdminClient indicesAdminClient = client.admin().indices(); indicesAdminClient.prepareCreate("calls") .setSettings(Settings.builder() .put("index.number_of_shards", 10) ) .addMapping("call", "{\n" +
" \"call\": {\n" +
" \"properties\": {\n" +
" \"id\": {\n" +
" \"type\": \"string\"}\n" +
" },\n" +
" \"number\": {\n" +
" \"type\": \"string\"}\n" +
" },\n" +
" \"name\": {\n" +
" \"type\": \"string\"\n" +
" }\n" +
" }\n" +
" }\n" +
" }")
.get(); String json = "{" +
"\"id\":\"1\"," + "\"number\":\"123333333\"," + "\"name\":\"Sharon Tries Elastic\"" + "}"; IndexResponse response = client.prepareIndex("calls", "call") .setSource(json) .get(); // Index name String _index = response.getIndex(); // Type name String _type = response.getType(); // Document ID (generated or not) String _id = response.getId(); // Version (if it's the first time you index this document, you will get: 1) long _version = response.getVersion(); client.close();
}
EDIT : was working accoridng to this example