# What is the \*right\* way to setup Elasticsearch on a service?

**URL:** <https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627>\
**Category:** Elasticsearch\
**Created:** [August 24, 2019, 4:14pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627 "2019-08-24T16:14:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Rosenzweig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacob_rosenzweig/32/47984_2.png) [@Jacob\_Rosenzweig](https://discuss.elastic.co/u/Jacob_Rosenzweig)\
**Post date:** [August 24, 2019, 4:14pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627/1 "2019-08-24T16:14:47Z")

</div>

I've used elasticsearch before on a small project. The project basically cataloged threads from a forum and presented them in a listview. I enabled search by connecting Elasticsearch through my MongoDB server via a Go daemon (Monstache). It worked but it felt fairly unintuitive and I couldn't help but think I was doing this the wrong way. Now I'm working on a new project and I actually use a SQL database instead to keep data, so I don't think the same trick can work again. So I have this question: what is the right way to setup Elasticsearch on a service? In other words, how should I connect Elasticsearch to my data? Should I simply dump the existing data in my SQL tables as documents into Elasticsearch? Should I only dump select information from each record (e.g. the necessary metadata) and store that in Elasticsearch? What happens when a new record is made? Do I index it immediately into Elasticsearch or do I collect a few new records and then batch insert it into Elasticsearch?

This is kind of a broad question, I understand. I just want to know what the normal way about it is. How does ELK typically fit into an existing application? I welcome guides, documentation, and best practice advice.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2019, 4:40pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627/2 "2019-08-24T16:40:10Z")

</div>

Welcome!

I shared most of my thoughts there: [http://david.pilato.fr/blog/2015/05/09/advanced-search-for-your-legacy-application/](http://david.pilato.fr/blog/2015/05/09/advanced-search-for-your-legacy-application/)

Basically, I'd recommend modifying the application layer if possible and send data to elasticsearch in the same "transaction" as you are sending your data to the database.

---

<div class="post-metadata">

**Author:** ![Jacob\_Rosenzweig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jacob_rosenzweig/32/47984_2.png) [@Jacob\_Rosenzweig](https://discuss.elastic.co/u/Jacob_Rosenzweig)\
**Post date:** [August 24, 2019, 5:22pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627/3 "2019-08-24T17:22:40Z")

</div>

So I basically just create an ElasticSearch bean (DAO) and couple it within my EntityService class. Whenever I create a new Entity, I'll also create it within ElasticSearch itself. So for each record in my SQL table, there's a coexisting document within Elasticsearch. This is better than an ETL as I get realtime searching.

One more question: if someone is building a service from the ground up and wants to incorporate elasticsearch, do they do the same thing (if they're sticking to a SQL database)? This guide is extremely helpful, by the way.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 24, 2019, 6:23pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627/4 "2019-08-24T18:23:29Z")

</div>

> [@Jacob\_Rosenzweig](#):
>
> One more question: if someone is building a service from the ground up and wants to incorporate elasticsearch, do they do the same thing (if they're sticking to a SQL database)?

I think so.

> [@Jacob\_Rosenzweig](#):
>
> This guide is extremely helpful, by the way.

Thanks!  
A "recent" version of the video is here:

https://player.vimeo.com/video/274560967?app_id=122963

---

<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:** [September 21, 2019, 6:23pm UTC](https://discuss.elastic.co/t/what-is-the-right-way-to-setup-elasticsearch-on-a-service/196627/5 "2019-09-21T18:23:30Z")

</div>

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