Setting the refresh interval from Java API

Anyone have an example on how to do this? Its easy with Curl but I'm
embedding this bulk indexing operation into my server.

-Matt

--
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.

Hey,

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")

Hope this helps...

--Alex

On Tue, Apr 2, 2013 at 4:00 AM, Matt Chambers yougotrooted@gmail.comwrote:

Anyone have an example on how to do this? Its easy with Curl but I'm
embedding this bulk indexing operation into my server.

-Matt

--
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.

--
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.

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);
}

try
{
Settings settings = ImmutableSettings.settingsBuilder().put(settings_map)
.build();

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.

-Matt

--
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.