Eclipse J2E: IndexNotFoundException[no such index]

Hello folks,

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.

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 https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-ids-query.html

Equivalent in Java: https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.3/java-term-level-queries.html#java-query-dsl-ids-query

1 Like