# Advice on schema - data modelling

**URL:** <https://discuss.elastic.co/t/advice-on-schema-data-modelling/8168>\
**Category:** Elasticsearch\
**Created:** [June 20, 2012, 1:23pm UTC](https://discuss.elastic.co/t/advice-on-schema-data-modelling/8168 "2012-06-20T13:23:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![towncafe](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@towncafe](https://discuss.elastic.co/u/towncafe)\
**Post date:** [June 20, 2012, 1:23pm UTC](https://discuss.elastic.co/t/advice-on-schema-data-modelling/8168/1 "2012-06-20T13:23:55Z")

</div>

Hi all,

I am a newbie on ES and currently trying to setup the ES schema for an  
existing real estate application currently using SQL for structured data  
search.

I am seeking some advice/validation on my approach of modelling/indexing  
the data which is originally stored in a relational DB. Search will mostly  
be on _structured data_ although keyword search will be added as well as a  
secondary feature.

So here are my assumptions:

1. Since most of the queries are location-specific I am considering using _sharding  
with routing based on the "city" field_. That way all searches for houses  
e.g. in New York would retrieve data from a single shard leading to better  
performance for the majority of the queries. For queries that are not  
city-specific all shards would need to be queried of course. Still this is  
better than routing based on the id of the houses that is totally random  
(autoincrement).

2. If it wasn't for my point above, we would be using _parent-child_ to  
model the relationship between a realtor and his houses. But I understand  
this would mean a realtor and all his houses would need to reside on the  
shame shard. So we are thinking of using a\* flat model\* where each listing  
also holds the information of the realtor (especially searchable fields -  
e.g. only return houses from realtors that are paying members).

3. The challenge here would be that we would need to _update all the houses  
of a specific realtor_ every time some of his data are modified. Is there  
an easy way to apply the same modification to all his indexed houses in one  
go? Or do we have to retrieve all his houses from the relational DB and  
then queue those so that they are reindexed?

Would be grateful for any comments on my assumptions 1 & 2 as well as any  
hints on my quesion 3.

thanks in advance

---

<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 6, 2017, 3:23am UTC](https://discuss.elastic.co/t/advice-on-schema-data-modelling/8168/2 "2017-07-06T03:23:14Z")

</div>


