higgs01
December 21, 2018, 10:08am
1
Hello
I'm trying to create an index:
client.indices().create(new CreateIndexRequest(indexName)
.settings(Settings.builder().put("index.number_of_replicas", 0))
.mapping(shipmentIndexConfiguration, XContentType.JSON),
RequestOptions.DEFAULT);
But Nothing is happening at all. Sometimes i get a exception that the request has timouted (after 30 seconds or so) but most of the time it just goes on for multiple hundred seconds.
If I check the log of the elasticsearch-server i don't see anything correlating to my issue.
If I try to create the index through Kibana everything works fine.
Elastic version: 6.4.2
Mapping Configuration(shipmentIndexConfiguration):
{
"mappings": {
"_doc": {
"properties": {
"documents": {
"properties": {
"importDateTime": {
"type": "date"
}
}
}
}
}
}
}
dadoonet
(David Pilato)
December 21, 2018, 11:09am
2
Here is how I'm creating an index using the HLRestClient:
public void createIndex(String index, boolean ignoreErrors, String indexSettings) throws IOException {
logger.debug("create index [{}]", index);
logger.trace("index settings: [{}]", indexSettings);
CreateIndexRequest cir = new CreateIndexRequest(index);
if (!isNullOrEmpty(indexSettings)) {
cir.source(indexSettings, XContentType.JSON);
}
try {
client.indices().create(cir, RequestOptions.DEFAULT);
} catch (ElasticsearchStatusException e) {
if (e.getMessage().contains("resource_already_exists_exception") && !ignoreErrors) {
throw new RuntimeException("index already exists");
}
}
}
The settings file is:
{
"settings": {
"number_of_shards": 1,
"index.mapping.total_fields.limit": 2000,
"analysis": {
"analyzer": {
"fscrawler_path": {
"tokenizer": "fscrawler_path"
}
},
"tokenizer": {
"fscrawler_path": {
"type": "path_hierarchy"
}
}
}
},
"mappings": {
"_doc": {
"dynamic_templates": [
This file has been truncated. show original
You can see that I'm configuring the whole settings (including number of shards and mapping) within the same json content.
Hope this helps.
higgs01
December 21, 2018, 12:43pm
4
thanks, i got it working with your example
system
(system)
Closed
January 18, 2019, 12:43pm
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.