user1849773 user1849773 - 3 months ago 10
Java Question

Eclipse J2E: IndexNotFoundException[no such index]

I have create a java client to connect to elasticsearch and request a document in several indexes called analytics-%{+YYYY.MM.dd}. Here is my code:

try {
client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(serverIpAddr), serverPort));
} catch (UnknownHostException e) {
e.printStackTrace();
}
GetResponse response = client.prepareGet("analytics*", "logs", "AVbgot3mAQOAFbgN9Rtz")
.setOperationThreaded(false)
.get();


However, I got the following error: [analytics*] IndexNotFoundException[no such index]

It works when I try with: 'analytics-2016.08.31' . However, for my purpose I need to request on multiple indexes.

Do you know how I can solve that ?

Thank you fopr your attention and your help.

Answer

If you don't know the index name, then you can't run a GET by ID which supposes you know index/type/id but you need to search across multiple indices.

You can have a look at IDs query and its Java form.