Can not connect to Elasticsearch from AngularJS

Hi,
I am using elastic search. I created a domain of elasticsearch. Is there is any way to connect the elastic search from my Angular 11. I used the elasticsearch.js library, but I can't able to connect with it for doing queries from the angular project. Can you help me to solve this problem?

Welcome!

Yes we can probably help. For that you will need to share with us some details like what is the error you are seeing, what is your code...

Hi,
Thank you for spending your valuable time with me. I am sharing the error message screenshot below. This error occurs when I connect the elastic search domain in Angular 11.

Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.

Instead, paste the text and format it with </> icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

Here this seems to be related to a logger.
Could you share how you created the client?

import { Injectable } from '@angular/core';
import * as elasticsearch from 'elasticsearch';
@Injectable({
providedIn: 'root'
})
export class ElasticSearchService {

constructor() {
if (!this.client) {
this.connect();
}
}

private client: elasticsearch.Client

private connect() {
debugger
this.client = new elasticsearch.Client({
host: 'https://search-amplify-elasti-1rdxoojhmejqc-cpb6vqldjs7ug4rourkkh5ftju.us-east-1.es.amazonaws.com/',
log: 'trace',
apiVersion: '7.2', // use the same version of your Elasticsearch instance
});

}

Hi sir,
This was the angular code, i am try to connect the elasticsearch.

Note that we don't support the service you are using here as it's not made by us.

Did you look at Cloud by Elastic, also available if needed from AWS Marketplace?

Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, Maps UI, Alerting and built-in solutions named Observability, Security, Enterprise Search and what is coming next :slight_smile: ...

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

okay sir

I think you might be missing the credentials when you call the service.

Hi sir,
That problem is solved. The problem is in our angular application-related not for elastic search. Thanks for your valuable comments.

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