# Optimize product/prices parent/child relation

**URL:** <https://discuss.elastic.co/t/optimize-product-prices-parent-child-relation/17552>\
**Category:** Elasticsearch\
**Created:** [May 16, 2014, 11:46am UTC](https://discuss.elastic.co/t/optimize-product-prices-parent-child-relation/17552 "2014-05-16T11:46:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_S\_V](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_s_v/32/1317_2.png) [@Alex\_S\_V](https://discuss.elastic.co/u/Alex_S_V)\
**Post date:** [May 16, 2014, 11:46am UTC](https://discuss.elastic.co/t/optimize-product-prices-parent-child-relation/17552/1 "2014-05-16T11:46:22Z")

</div>

Hi

Help me please to find right solution for next case:

I have products and location prices. So, each product has different price  
in different locations (stores).

Simplest query is:

_"search products, display minimum price and sort by this price"_

Advanced query is:

\*"search products within some price range, location region, display minimum  
price and sort by this price" \*

Here is my mapping (I'm thinking about parent/child schema)  
{  
product: {  
properties: {  
title: { type: "string" },  
description: { type: "string" },  
options: { type: "string" }  
}  
},  
price: {  
\_parent: { type: "product" },  
properties: {  
available: { type: "integer" },  
price: { type: "float" },  
location: { type: "geo\_point" },  
city: { type: "string" }  
}  
}  
}

One idea is to query products, use top\_children in combination with min  
score, where score is the price.  
But how to optimize it for cases, when product has thousands of prices?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7a7dae72-cc29-4279-ab6b-6541756c9513%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7a7dae72-cc29-4279-ab6b-6541756c9513%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:28am UTC](https://discuss.elastic.co/t/optimize-product-prices-parent-child-relation/17552/2 "2017-07-06T01:28:57Z")

</div>


