Working with aliases using Java API

Hi everybody,

like many people here I am planing to use ES and currently I am
preparing a kind of a proof of concept. So far I can tell that ES is a
briliant piece of software and Shay is doing an incredible job
developing it.

Everything went smooth so far but now I am kind of lost :slight_smile:

I am planing to use ES in the following scenario. From a customer I
have a data feed that contains all the data I need to index. I have no
information which items have changed or were added or deleted. That
means that I will periodically do a full reindex. It is not a problem
because we are talking about ~200,000 documents that have ~50 MB in
total. This way is also the the easiest way for the client to export
their data.

From my point of view the right way is to do every reindex into a
newly created index and use an alias for client applications to
connect to the right one. That means that after a successful reindex I
need to change the alias and I can delete the old index.

And my problem is that I have no idea how to work with aliases using
the Java API :slight_smile: I have found a thread here where Shay explained how to
get a list of existing aliases. I can do that, so I know the name of
the old index I can delete eventually. But I don't know how to alter
the alias using the Java API. Could somebody please help me? I expect
that I will end up having to prepare and send the JSON request by hand
(so maybe I am looking for a way how to send an arbitrary request
using the Java API). That is fine by me. I just need a little help
where to look :slight_smile: Thanks!

A.

Heya, here is a sample:

client.admin().indices().prepareAliases().addAlias("my_index",
"my_alias").removeAlias("my_old_index", "my_alias").execute().actionGet();

On Thu, Sep 1, 2011 at 12:01 PM, Andrew ondrej.nespor@gmail.com wrote:

Hi everybody,

like many people here I am planing to use ES and currently I am
preparing a kind of a proof of concept. So far I can tell that ES is a
briliant piece of software and Shay is doing an incredible job
developing it.

Everything went smooth so far but now I am kind of lost :slight_smile:

I am planing to use ES in the following scenario. From a customer I
have a data feed that contains all the data I need to index. I have no
information which items have changed or were added or deleted. That
means that I will periodically do a full reindex. It is not a problem
because we are talking about ~200,000 documents that have ~50 MB in
total. This way is also the the easiest way for the client to export
their data.

From my point of view the right way is to do every reindex into a
newly created index and use an alias for client applications to
connect to the right one. That means that after a successful reindex I
need to change the alias and I can delete the old index.

And my problem is that I have no idea how to work with aliases using
the Java API :slight_smile: I have found a thread here where Shay explained how to
get a list of existing aliases. I can do that, so I know the name of
the old index I can delete eventually. But I don't know how to alter
the alias using the Java API. Could somebody please help me? I expect
that I will end up having to prepare and send the JSON request by hand
(so maybe I am looking for a way how to send an arbitrary request
using the Java API). That is fine by me. I just need a little help
where to look :slight_smile: Thanks!

A.

1 Like

Hi,

thanks! It is way easier than I expected :slight_smile:

A.

On 1 zรกล™, 12:30, Shay Banon kim...@gmail.com wrote:

Heya, here is a sample:

client.admin().indices().prepareAliases().addAlias("my_index",
"my_alias").removeAlias("my_old_index", "my_alias").execute().actionGet();

On Thu, Sep 1, 2011 at 12:01 PM, Andrew ondrej.nes...@gmail.com wrote:

Hi everybody,

like many people here I am planing to use ES and currently I am
preparing a kind of a proof of concept. So far I can tell that ES is a
briliant piece of software and Shay is doing an incredible job
developing it.

Everything went smooth so far but now I am kind of lost :slight_smile:

I am planing to use ES in the following scenario. From a customer I
have a data feed that contains all the data I need to index. I have no
information which items have changed or were added or deleted. That
means that I will periodically do a full reindex. It is not a problem
because we are talking about ~200,000 documents that have ~50 MB in
total. This way is also the the easiest way for the client to export
their data.

From my point of view the right way is to do every reindex into a
newly created index and use an alias for client applications to
connect to the right one. That means that after a successful reindex I
need to change the alias and I can delete the old index.

And my problem is that I have no idea how to work with aliases using
the Java API :slight_smile: I have found a thread here where Shay explained how to
get a list of existing aliases. I can do that, so I know the name of
the old index I can delete eventually. But I don't know how to alter
the alias using the Java API. Could somebody please help me? I expect
that I will end up having to prepare and send the JSON request by hand
(so maybe I am looking for a way how to send an arbitrary request
using the Java API). That is fine by me. I just need a little help
where to look :slight_smile: Thanks!

A.