Hi,
Full disclosure im a newb at this:
I have been trying to create an index using the below code:
private boolean createIndices( ) {
String indexName="279"
String typeName="badge_type";
String mapping={\"badge_type\": {\"_type\":{\"store\":\"true\"},"
+ "\"_index\":{\"enabled\":\"true\"},"
+ "\"_id\":{\"path\":\"badge_type_id\"},"
+ "\"dynamic\":\"strict\","
+ "\"properties\":{
\"badge_type_id\":{\"type\":\"string\",\"store\":\"true\",\"index\":\"not_analyzed\"},"
+
"\"name\":{\"type\":\"string\",\"store\":\"true\",\"index_analyzer\":\"autocomplete\",\"search_analyzer\":\"standard\"},"
+ "\"description\":{\"type\":\"string\",\"store\":\"true\"} "
+ " } } };
try {
if (!NodeOperation.INSTANCE.getNode().client().admin().indices()
.prepareExists(indexName).execute().actionGet().isExists()) {
System.out.println("index does not exist, create it and : "
+ indexName);
log.trace("CREATE INDEX: " + indexName);
String settings = "{\"aliases\": { "
+ "\"content\": {}, \"school\": {}},"
+ "\"settings\":{"
+ "\"index\":{"
+ "\""+indexName+"\":{"
+ "\"analysis\":{\"analyzer\" : [{"
+ "\"autocomplete\" : { "
+ "\"type\" :\"custom\","
+ "\"tokenizer\":\"keyword\","
+ "\"filter\":[\"lowercase\", \"autocomplete_filter\" ] } "
+ "},{"
+ "\"email_custom\" : { "
+ "\"type\" :\"custom\","
+ "\"tokenizer\":\"uax_url_email\","
+ "\"filter\":[\"lowercase\", \"autocomplete_filter\" ] } "
+ "}],\"filter\":"
+ "{\"autocomplete_filter\":{ \"type\" :\"edge_ngram\","
+ "\"min_gram\":\"2\"," + "\"max_gram\":20" + " }"
+ " }" + " } " + "}}}}";
CreateIndexRequestBuilder irb = NodeOperation.INSTANCE
.getNode().client().admin().indices()
.prepareCreate(indexName).setSource(settings);
irb.execute().actionGet();
}
if (!isTypeExist(indexName, typeName)) {
System.out
.println("type does not exist create it: " + typeName);
PutMappingResponse res = NodeOperation.INSTANCE.getNode()
.client().admin().indices()
.preparePutMapping(indexName).setType(typeName)
.setSource(mapping).setIndices(indexName).execute()
.actionGet();
return res.isAcknowledged();
} else {
return true;
}
} catch (Exception e) {
e.getMessage();
}
return false;
}
the index is created with the following setings:
{
"279" : {
"settings" : {
"index" : {
"settings" : {
"analysis" : {
"filter" : {
"autocomplete_filter" : {
"type" : "edge_ngram",
"min_gram" : "2",
"max_gram" : "20"
}
},
"analyzer" : [ {
"autocomplete" : {
"filter" : [ "lowercase", "autocomplete_filter" ],
"type" : "custom",
"tokenizer" : "keyword"
}
}, {
"email_custom" : {
"type" : "custom",
"filter" : [ "lowercase", "autocomplete_filter" ],
"tokenizer" : "uax_url_email"
}
} ]
}
},
"number_of_shards" : "5",
"number_of_replicas" : "1",
"version" : {
"created" : "1030499"
},
"uuid" : "T4a3_p3GSkKpui5zKhfSqQ"
}
}
}
}
but mapping cannot be added to the type, i get the following error:
[2014-12-02 15:11:32,828][INFO ][cluster.metadata ] [War Eagle]
[279] creating index, cause [api], shards [5]/[1], mappings []
[2014-12-02 15:11:34,229][DEBUG][action.admin.indices.mapping.put] [War
Eagle] failed to put mappings on indices [[279]], type [badge_type]
org.elasticsearch.index.mapper.MapperParsingException: Analyzer
[autocomplete] not found for field [name]
at
org.elasticsearch.index.mapper.core.TypeParsers.parseField(TypeParsers.java:220)
at
org.elasticsearch.index.mapper.core.StringFieldMapper$TypeParser.parse(StringFieldMapper.java:153)
at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:289)
at
org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:217)
at
org.elasticsearch.index.mapper.object.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:136)
at
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:209)
at
org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:190)
at
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:440)
at
org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:503)
at
org.elasticsearch.cluster.service.InternalClusterService$UpdateTask.run(InternalClusterService.java:328)
at
org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:153)
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)
any help to finding out where im going wrong will be greatly appreciated.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/b33ab998-935c-4cb7-ba99-35106b9f7c55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.