there are several possibilities. If you want to do it manually you can
issue a refresh request (possible if you have an IndicesAdminClient). If
you want to change the settings, you can fire an updateSettingsRequest for
the index.
// you need a settings builder for the changed settings as additional
parameter here
client.admin().indices().prepareUpdateSettings(...)
node.client().admin().indices().prepareRefresh("yourindex")
Here's the internal snippet that I use to change one of two settings for an
existing index: The number of replicas, and the index refresh rate. There's
an enum defined with the two enumerated setting values that I currently
need to support in the Java code. The index is simply a Java String name of
an index. The index typically must exist for me: I currently prefer to
create an index with all settings and mappings instead of let the defaults
take over. But that's just me.
Map<String, String> settings_map = new HashMap<String, String>();
switch (setting)
{
case NUMBER_OF_REPLICAS:
settings_map.put("index.number_of_replicas", value);
break;
case REFRESH_INTERVAL:
settings_map.put("index.refresh_interval", value);
break;
default:
throw new YourOwnException("Unsupported setting: "
+ setting + " with value " + value);
}
UpdateSettingsRequestBuilder usrb = client.admin().indices()
.prepareUpdateSettings();
usrb.setIndices(index);
usrb.setSettings(settings);
usrb.execute().actionGet();
}
catch (ElasticSearchException e)
{
// TODO: Throw your own exception here if you wish
}
On Monday, April 1, 2013 10:00:33 PM UTC-4, Matt Chambers wrote:
Anyone have an example on how to do this? Its easy with Curl but I'm
embedding this bulk indexing operation into my server.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.