# Which is the best way to index the data from relational database

**URL:** <https://discuss.elastic.co/t/which-is-the-best-way-to-index-the-data-from-relational-database/141870>\
**Category:** Elasticsearch\
**Created:** [July 27, 2018, 4:56am UTC](https://discuss.elastic.co/t/which-is-the-best-way-to-index-the-data-from-relational-database/141870 "2018-07-27T04:56:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [July 27, 2018, 8:26am UTC](https://discuss.elastic.co/t/which-is-the-best-way-to-index-the-data-from-relational-database/141870/2 "2018-07-27T08:26:24Z")

</div>

My advice:

Think about the use case, not the current implementation.  
Basically ask yourself: "What type of data my user will be searching for?".

As an example, let's say that users want to search for employees. Then index employees.

2nd question is "What kind of attributes do my users will use to search?". Let's say "company name", "company website" and "employee name". Then just store those values within each document, like:

```auto
PUT employees/_doc/david
{
  "name": "David XYZ",
  "company": {
    "name": "elastic",
    "website": "https://elastic.co"
  }
}

```

So don't try to reimplement relational model if it's not absolutely needed but just focus first on the use case.

For the record 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/)

---

_[View the full topic](https://discuss.elastic.co/t/which-is-the-best-way-to-index-the-data-from-relational-database/141870)._
