Which Node.js client should I use for Elastic search?

Which package should I use as a Node.js client to connect to Elastic search?

I've found this one: elasticsearch-js (GitHub - elastic/elasticsearch-js: Official Elasticsearch client library for Node.js)
It seems to be regularly updated.

But there's also this one: enterprise-search-js (GitHub - elastic/enterprise-search-js: Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.)
There's somehow no updates going on right now.

Which one should I use? Is the first one going to replace the second one?

I've also seen this package: app-search-javascript (GitHub - elastic/app-search-javascript: Elastic App Search Official JavaScript Client).
It seems to be intended for a browser environment than in Node.js. Am I right?

Hi @cosieLq,

Welcome to the community! If you're looking to connect to Elasticsearch and do operations such as index management and querying within your JavaScript app, then it is Elasticsearch Node.js client that you need (i.e. the first one):

The second one is for Elastic App and Workplace Search rather than vanilla Elasticsearch.

Hope that helps!

Hi @carly.richmond ,

Thank you very much for your response!
What's the difference between Elastic App Search and vanilla Elasticsearch? I cannot really tell it...

No worries at all @cosieLq ! It can be a bit confusing so I'm happy to elaborate.

App Search is a set of additional tools built on top of Elasticsearch to make it easier for enterprises to build search experiences quicker. So if you have a look at the documentation it includes tools such as the web crawler. I would recommend having a look at the guides to get a feel of what tools are in there.

I hope that is a bit clearer. If not, feel free to let us know what you're trying to do with Elasticsearch and we can try to help. But when you mentioned you want to connect to Elasticsearch directly within a Node.js app it sounded like the Elasticsearch Node.js client was the right one for you.

@carly.richmond I've checked the documentation that you sent and our tech stack. It turns out that we're using Elastic App Search. Therefore, in our case, I should use this package as our client:
enterprise-search-js. Did I understand it correctly?

But it seems not much is going on with this package on GitHub. Is this package actively being maintained and updated?

Can you say a bit more about what you're trying to do within your Node.js app with Elastic App Search? To best confirm which client to use I need a bit more information.

Yes! I'm trying to conduct search such as querying and looking for suggestions.

We use Next.js as the front-end of our website. Because we want to connect to Elastic from the front-end server instead of from the browser, it'll be a Node.js environment.

Thanks for confirming. Looking at the activity on the enterprise search client I agree with your concern regarding recent updates.

My general advise is if you need to use specific features of App search as covered in the docs use the enterprise client, but for vanilla searching it might be worth using the generic Javascript client.

Hope that helps!

Oké! I've checked the documentation of App search. It turns out that we're using the Engine API which seems missing in the vanilla searching.

Therefore, I think we will stick to this client: GitHub - elastic/enterprise-search-js: Official Node.js client for Elastic Enterprise Search, App Search, and Workplace Search.
Hopefully this package will remain actively updated, and I look very much forward to the next release (hopefully soon)!

Thank you again for your answers and the great products of Elastic!

1 Like

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