0

I'm trying to create document in elastic search using Alias with the help of Java RestHighLevelClient.

IndexName = items-0 (suffix is indent to increment over time)
Alias = write-inventory-items

I've created this alias to the index. Since I'm planning to update in index name during reindexing, I don't want to depend on the indexName.

Looks like it's a simple use case, but I'm not able to find any way to do it.

Psycho
  • 123
  • 1
  • 8

1 Answers1

0

Just use the alias instead of the index name in your Java code. For the client, it´s transparent (invisible) if the request-target is an index or alias.

Example:

IndexRequest indexRequest = new IndexRequest("write-inventory-items")
.source("user", "kimchy",
    "postDate", new Date(),
    "message", "trying out Elasticsearch");
ibexit
  • 3,465
  • 1
  • 11
  • 25