# existsAlias returns false

**URL:** https://discuss.elastic.co/t/existsalias-returns-false/322455
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [January 4, 2023, 11:37am UTC](https://discuss.elastic.co/t/existsalias-returns-false/322455 "2023-01-04T11:37:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ewolfman](https://avatars.discourse-cdn.com/v4/letter/e/5f8ce5/32.png) [@ewolfman](https://discuss.elastic.co/u/ewolfman)
#### Post date: [January 4, 2023, 11:37am UTC](https://discuss.elastic.co/t/existsalias-returns-false/322455/1 "2023-01-04T11:37:26Z")

</div>

Hi,

Using RestHighLevelClient with Elasticsearch 7.17.7 both client and server.  
For new records coming in I check wether an expected alias exists.

```auto
boolean exists = client.indices().existsAlias(requestWithAlias, RequestOptions.DEFAULT);

```

At times I can see this API return false for an alias that was **created long ago**. This can even happen with 2 almost consecutive calls with just a second or so in between.

An example from my own logs (truncated logs):

> 7:30:59.141 AM alias exists  
> 7:31:01.279 AM alias does not exist

According to the [documentation](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-exists-alias.html#java-rest-high-exists-alias-sync):

> In cases where the server returns a `4xx` or `5xx` error code, the high-level client tries to parse the response body error details instead and then throws a generic `ElasticsearchException` and adds the original `ResponseException` as a suppressed exception to it.

But because there was no exception, I assume that some code other than 200 was returned (looking into the Java code, 200 will return true otherwise false - so I guess a 404 was returned but I don't know for sure).

I was thinking perhaps there was a timeout, but shouldn't this have resulted in an exception?

I can also see some logs from ES mentioning memory from time to time (not necessarily adjacent to the example above):

> attempting to trigger G1GC due to high heap usage

followed by:

> GC did bring memory usage down

Any idea why existsAlias sometimes returns false for an alias that exists for sure?

---

<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: [February 1, 2023, 11:37am UTC](https://discuss.elastic.co/t/existsalias-returns-false/322455/2 "2023-02-01T11:37:34Z")

</div>

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