In java,how do you query an index by alias

(Mr.xian) #1

In JAVA, if the alias of the index my-index is my-alias, how do I query my-index based on my-alias
That is, how do you query an index by alias
Is it the following?

GetAliasesResponse a=esClient.admin().indices()

But the above code returns all indexes

(Tim Vernum) #2

I assume by "query my-index based on my-alias", you simply want to perform a search on "my-alias", in which case you just do exactly what you would do for an index, but use the alias name.

Largely speaking, you use aliases by passing them in anywhere where an index name is expected. (This is not true in every case, but is true for search and get).

(Mr.xian) #3

Thank you,I didn't make it clear, I mean, how do I implement the following API in JAVA

GET /_alias/my-alias

(Tim Vernum) #4

Which Java client, and which version?

(Mr.xian) #5

TransportClient 6.5

(system) closed #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.