# I have a issue: \[es/index\] failed: \[index\_not\_found\_exception\] no such index when I write data into datastream using java client 8.5.3

**URL:** <https://discuss.elastic.co/t/i-have-a-issue-es-index-failed-index-not-found-exception-no-such-index-when-i-write-data-into-datastream-using-java-client-8-5-3/322035>\
**Category:** Elasticsearch\
**Tags:** datastreams\
**Created:** [December 27, 2022, 11:38am UTC](https://discuss.elastic.co/t/i-have-a-issue-es-index-failed-index-not-found-exception-no-such-index-when-i-write-data-into-datastream-using-java-client-8-5-3/322035 "2022-12-27T11:38:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuxiao415](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xuxiao415/32/115264_2.png) [@xuxiao415](https://discuss.elastic.co/u/xuxiao415)\
**Post date:** [December 27, 2022, 11:38am UTC](https://discuss.elastic.co/t/i-have-a-issue-es-index-failed-index-not-found-exception-no-such-index-when-i-write-data-into-datastream-using-java-client-8-5-3/322035/1 "2022-12-27T11:38:53Z")

</div>

I have a es cluster with three data nodes. I create a data stream: myindex. when I write data into data stream using java client 8.5.3, I met a problem:

```auto
co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/index] failed: [index_not_found_exception] no such index [myindex]

	at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:282)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:148)
	at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:962)

```

This problem does not always occur, only occasionally.

my test code is:

```auto
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.OpType;
import co.elastic.clients.elasticsearch.core.IndexRequest;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class ElasticSearchTest {
    @Test
    public void testDataStream() {
        RestClient restClient = RestClient.builder(
                new HttpHost("mydomain", 80)).build();

        // Create the transport with a Jackson mapper
        ElasticsearchTransport transport = new RestClientTransport(
                restClient, new JacksonJsonpMapper());

        // And create the API client
        ElasticsearchClient esClient = new ElasticsearchClient(transport);
        Map<String, String> document = new HashMap<>();
        document.put("@timestamp", "2022-12-27 15:08:06.131");
        document.put("rt", "123456");
        try {
            esClient.index(IndexRequest.of(item -> item.index("myindex").opType(OpType.Create).document(document)));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

```

java client maven dep:

```auto
<dependency>
            <groupId>co.elastic.clients</groupId>
            <artifactId>elasticsearch-java</artifactId>
            <version>8.5.3</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.12.3</version>
        </dependency>
        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
            <version>2.0.1</version>
        </dependency>

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 24, 2023, 11:39am UTC](https://discuss.elastic.co/t/i-have-a-issue-es-index-failed-index-not-found-exception-no-such-index-when-i-write-data-into-datastream-using-java-client-8-5-3/322035/2 "2023-01-24T11:39:43Z")

</div>

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