2

I have a web site that frontend developed by vue.js(SPA) and backend developed by node.js. I want to use Elasticsearch in the search box at main page. Should I call search query from client to elasticsearch or client to nodejs backend and then to elasticsearch?

What is the best practice? What are the pros and cons?

Suleyman Arıkan
  • 503
  • 1
  • 4
  • 7

1 Answers1

2

Calling it from front end takes you to expose your ES server in the public network. You get in security risks such as exposing your database.

Calling it from backend avoids public network exposition and also give you a chance to implement a controller to handle search validations and reponse status.

In my personal experience the backend way is better for ES queries.

refs:

https://discuss.elastic.co/t/is-it-safe-to-expose-elasticsearch-to-the-internet/246862/5

https://discuss.elastic.co/t/is-it-safe-to-expose-elasticsearch-to-the-internet/247041