Hey,

What is the best way to design indexes in elasticsearch? 

I mean in terms of normalization vs denormalization

So am I right in thinking that because elasticsearch is a document database 
we don't worry about having a denormalized model?

So let's say I'm in the "fruit" domain and I have a set of apple varieties 
say:
Bailey
Baldwin
Ballyfatten
Beacon
Beauty of Bath
Belle de Boskoop agm
Ben Davis
Beverly Hills
Bismarck
Blenheim Orange agm
Bloody Ploughman
Bottle Greening
Braeburn
Bramley (Bramley's Seedling) agm
Bravo de Esmolfe
Breedon Pippin
Brina
Byfleet Seedling

I know the name will always be less than say 70 characters so if I have an 
index say 

stock {
 apple_variety,
 count,
 shop,
 expiry_date
}


with for example : 
stock =  {
"Bailey", 50, "store1", "01/01/2015",
"Baldwin", 150, "store1", "01/01/2015",
"Ballyfatten", 250, "store1", "01/01/2015",
"Beacon", 50, "store1", "01/01/2015",
"Beauty of Bath", 250, "store2", "01/01/2015"
 }

is that better than 
 variety {
  variety_id,
  variety_name
}

with {
 1, "Bailey",
 2, "Baldwin",
 3, "Ballyfatten",
 4, "Beacon",
 5, "Beauty of Bath",
 6, "Belle de Boskoop agm",
 7, "Ben Davis",
 8, "Beverly Hills",
 9, "Bismarck",
 10, "Blenheim Orange agm",
 11, "Bloody Ploughman",
 12, "Bottle Greening",
 13, "Braeburn",
}",
And
stock =  {
1, 50, "store1", "01/01/2015",
2, 150, "store1", "01/01/2015",
3, 250, "store1", "01/01/2015",
4, 50, "store1", "01/01/2015",
5, 250, "store1", "01/01/2015"
 }

I am thinking that in production there will be advantages to having 
denormalised data 
particularly say event of schema change then the data can remain in place 
with addition of fields

If on other hand a new apple variety is insert or removed then the meaning 
of apple_id : 1 might accidentally change and cause grief ?

Thoughts ?

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/95dfa1c9-8e26-4c1b-8009-506870ca4a24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to