Hi guys.
I use single-node ES application with embedded node (i.e. 1 node cluster,
node is a data node, client is obtained as
NodeBuilder.nodeBuilder().build().client()).
I have elasticsearch.yml file in my resources, where I have refresh_inteval
set to "5s".
I also have index_settings.json file and some xxx_mapping.json files in my
resources, attached via
public void ensureIndexWithMappings(String... mappings) {
try {
final AdminClient admin = esClient.admin();
if(!admin.indices().prepareExists(indexName).execute().actionGet().isExists())
{
CreateIndexRequestBuilder indexBuilder =
admin.indices().prepareCreate("index").setSettings(
ImmutableSettings.settingsBuilder().loadFromClasspath("index_settings.json"
)));
for (String mapping : mappings) {
indexBuilder.addMapping(mapping,
new Scanner(new ClassPathResource(String.format(
MAPPING_FILENAME_PATTERN, mapping)).getInputStream(), "UTF-8").useDelimiter(
"\A").next());
}
indexBuilder.execute().actionGet();
}
// wait until we're done
admin.cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
} catch (ElasticSearchException ese) {
LOGGER.error("Failed to initialize index {}", indexName, ese);
throw ese;
} catch (IOException ioe) {
LOGGER.error("Failed to read mapping definitions for index {}.
Definitions are: {}", indexName, mappings, ioe);
throw new RuntimeException(ioe);
}
}
elasticsearch.yml contains
A time setting controlling how often the refresh operation will be
executed.
Defaults to 1s. Can be set to -1 in order to disable it.
index.refresh_interval: 5s
index_settings.json contains the same refresh_inteval property just for a
test.
{
"index" : {
"refresh_interval" : "6s",
"analysis" : {
"analyzer" : {
"ngram_analyzer" : {
type : "custom",
"tokenizer" : "standard",
"filter" : ["lowercase", "stop", "substrings"]
}
},
"filter" : {
"substrings" : {
"type" : "edgeNGram",
"min_gram" : 2,
"max_gram" : 10
}
}
}
}
}
My question is quite simple - what is the correct (preferred) way to push
settings - via global .yml file or via admin.indices().prepareCreate("index"
).setSettings(...)?
In my case, analysis section is correctly applied but refresh_interval "6s"
is never read from this JSON - even if I comment out "5s" setting in .yml
file.
-Max
--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.