# New to Elasticsearch, need help to create an index

**URL:** <https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664>\
**Category:** Elasticsearch\
**Created:** [October 22, 2016, 1:46pm UTC](https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664 "2016-10-22T13:46:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabianmossberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabianmossberg/32/12654_2.png) [@fabianmossberg](https://discuss.elastic.co/u/fabianmossberg)\
**Post date:** [October 22, 2016, 1:46pm UTC](https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664/1 "2016-10-22T13:46:24Z")

</div>

I'm completley new to Elasticsearch but I run a website with quoite a lot of data and just MySQL doesn't do it for me anymore.

I would love some help on how to set up my index. My site has users, each user can create as many blogs they want to. A blog has posts. Every post has a location\_id. The locations table have many locations.

Every user will have a currently\_in\_location\_id from where they were last as well as a from\_location\_id that tells where they are from.

The locations table will rarely change, but it will get things added. But users currently\_in\_location\_id will change every few days.

I'm not sure how i should build the index, especially in regards to the locations as a posts location could be "Brazil", or it could be "Copenhagen, Denmark" or "Panjim, Goa, India"

Below i have tried to give an examble of how my data can look:

**STRUCTURE OF THE DATA**

> **USERS**
> 
> id  
> username  
> firstname  
> lastname  
> from\_location\_id  
> currently\_in\_location\_id  
> email  
> date\_of\_birth
> 
> **LOCATIONS**
> 
> location\_id  
> parent\_location\_id  
> location\_name  
> location\_geo\_lat  
> locatoin\_geo\_lng  
> location\_type
> 
> **BLOGS**
> 
> blog\_id  
> user\_id  
> blog\_title
> 
> **POSTS**
> 
> post\_id  
> blog\_id  
> user\_id  
> location\_id  
> post\_geo\_lat  
> post\_geo\_lng  
> post\_title  
> post\_body  
> published\_at  
> updated\_at

**BELOW IS SOME SAMPLE DATA**

> **USER**
> 
> user\_id: 1  
> username: bob  
> firstname: bob  
> lastname: bobson  
> from\_location\_id: 7  
> currently\_in\_location\_id: 2  
> email: [bob@bob.com](mailto:bob@bob.com)  
> date\_of\_birth: 1985-10-26
> 
> **LOCATION (There is no predefined depht here, the child relations goes on for 0-10 levels)**
> 
> location\_id: 1  
> parent\_location\_id: NULL  
> location\_name: Russia  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: COUNTRY
> 
> location\_id: 2  
> parent\_location\_id: 1  
> location\_name: Moscow  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: CITY
> 
> location\_id: 3  
> parent\_location\_id: NULL  
> location\_name: Sweden  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: COUNTRY
> 
> location\_id: 4  
> parent\_location\_id: 3  
> location\_name: Stockholm County  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: COUNTY
> 
> location\_id: 5  
> parent\_location\_id: 4  
> location\_name: Stockholm  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: CITY
> 
> location\_id: 6  
> parent\_location\_id: 5  
> location\_name: Gamla Stan  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: NEIGHBORHOOD
> 
> location\_id: 7  
> parent\_location\_id: 3  
> location\_name: Kalmar  
> location\_geo\_lat: 0  
> locatoin\_geo\_lng: 0  
> location\_type: CITY
> 
> **BLOG**
> 
> blog\_id: 1  
> user\_id: 1  
> blog\_title: Bob's blog
> 
> **POST**
> 
> post\_id: 1  
> blog\_id: 1  
> user\_id: 1  
> location\_id: 2  
> post\_geo\_lat: 0  
> post\_geo\_lng: 0  
> bost\_title: Hello Moscow  
> post\_body: I have now arrived in Moscow, it's great  
> published\_at: 2016-20-21 13:37:00  
> updated\_at: 2016-10-21 00:42:00

Any advice on how to build my index for this data is appreciated!

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [October 24, 2016, 7:49am UTC](https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664/2 "2016-10-24T07:49:37Z")

</div>

I think it would be best for you start with the [data modeling chapter](https://www.elastic.co/guide/en/elasticsearch/guide/current/modeling-your-data.html) of the ES Definitive Guide.

Hope this helps,  
Isabel

---

<div class="post-metadata">

**Author:** ![fabianmossberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabianmossberg/32/12654_2.png) [@fabianmossberg](https://discuss.elastic.co/u/fabianmossberg)\
**Post date:** [October 24, 2016, 5:13pm UTC](https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664/3 "2016-10-24T17:13:38Z")

</div>

Thank you! I'll read through it!

---

<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:** [July 5, 2017, 10:10pm UTC](https://discuss.elastic.co/t/new-to-elasticsearch-need-help-to-create-an-index/63664/4 "2017-07-05T22:10:10Z")

</div>


