# Different field according to categories

**URL:** <https://discuss.elastic.co/t/different-field-according-to-categories/12529>\
**Category:** Elasticsearch\
**Created:** [June 24, 2013, 7:18pm UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529 "2013-06-24T19:18:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![oto\_iashvili](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@oto\_iashvili](https://discuss.elastic.co/u/oto_iashvili)\
**Post date:** [June 24, 2013, 7:18pm UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/1 "2013-06-24T19:18:12Z")

</div>

Hi,

im trying to use elasticsearch to search through products. If product is a  
car for instance, it will have some field like "color", "brand", "model",  
"km", ...  
If it is clothes, it will only have "color", "size", ...  
I would like to index all this info in elastic to be able then to search  
cars with km between aaa km and bbb km, and / or xxxx model, same for  
clothes or any other products.

how can I create such field(s) in elasticsearch ? I want all products to be  
in same index, so user can search through all products, but also if user  
search a type a product, then he should be able to specify some more  
details according to this kind of product.

I was thinking about array field, but does that mean that all products will  
have all fields corresponding to all type of products even if some fields  
are not relevant with some products (ie clothes will have km field ??) ? Or  
is it possible on indexing to put just info needed corresponding to each  
product ?

thanks

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 24, 2013, 8:22pm UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/2 "2013-06-24T20:22:01Z")

</div>

Hey,

simply create different types for each kind of product in one index. Still  
your application will need to fire off different kind of searches depending  
on the product you are searching for.

Also check out this presentation from Clinton to get up and running  
quickly, along with the reference documentation.

> **[Down and dirty with Elasticsearch](https://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch)**
>
> Down and dirty with Elasticsearch - Download as a PDF or view online for free

--Alex

On Mon, Jun 24, 2013 at 9:18 PM, oto iashvili  
[optimum.dulopin@laposte.net](mailto:optimum.dulopin@laposte.net)wrote:

> Hi,
> 
> im trying to use elasticsearch to search through products. If product is a  
> car for instance, it will have some field like "color", "brand", "model",  
> "km", ...  
> If it is clothes, it will only have "color", "size", ...  
> I would like to index all this info in elastic to be able then to search  
> cars with km between aaa km and bbb km, and / or xxxx model, same for  
> clothes or any other products.
> 
> how can I create such field(s) in elasticsearch ? I want all products to  
> be in same index, so user can search through all products, but also if user  
> search a type a product, then he should be able to specify some more  
> details according to this kind of product.
> 
> I was thinking about array field, but does that mean that all products  
> will have all fields corresponding to all type of products even if some  
> fields are not relevant with some products (ie clothes will have km field  
> ??) ? Or is it possible on indexing to put just info needed corresponding  
> to each product ?
> 
> thanks
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![oto\_iashvili](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@oto\_iashvili](https://discuss.elastic.co/u/oto_iashvili)\
**Post date:** [June 25, 2013, 1:14pm UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/3 "2013-06-25T13:14:16Z")

</div>

thanks for answer. It seems to be what I need. But Is there a way to  
optimize or to make kind of inheritance, as all products have some common  
fields, like price, category, date, images, ...

On Monday, June 24, 2013 10:22:01 PM UTC+2, Alexander Reelsen wrote:

> Hey,
> 
> simply create different types for each kind of product in one index. Still  
> your application will need to fire off different kind of searches depending  
> on the product you are searching for.
> 
> Also check out this presentation from Clinton to get up and running  
> quickly, along with the reference documentation.  
> [Down and dirty with Elasticsearch | PPT](http://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch)
> 
> --Alex
> 
> On Mon, Jun 24, 2013 at 9:18 PM, oto iashvili \<[optimum...@laposte.net](mailto:optimum...@laposte.net)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > im trying to use elasticsearch to search through products. If product is  
> > a car for instance, it will have some field like "color", "brand", "model",  
> > "km", ...  
> > If it is clothes, it will only have "color", "size", ...  
> > I would like to index all this info in elastic to be able then to search  
> > cars with km between aaa km and bbb km, and / or xxxx model, same for  
> > clothes or any other products.
> > 
> > how can I create such field(s) in elasticsearch ? I want all products to  
> > be in same index, so user can search through all products, but also if user  
> > search a type a product, then he should be able to specify some more  
> > details according to this kind of product.
> > 
> > I was thinking about array field, but does that mean that all products  
> > will have all fields corresponding to all type of products even if some  
> > fields are not relevant with some products (ie clothes will have km field  
> > ??) ? Or is it possible on indexing to put just info needed corresponding  
> > to each product ?
> > 
> > thanks
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 26, 2013, 6:33am UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/4 "2013-06-26T06:33:47Z")

</div>

Hey,

you can configure a default settings for all types created in your search  
instance (I am however not a big fan of it, but maybe it helps in your  
specific usecase). See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--Alex

On Tue, Jun 25, 2013 at 3:14 PM, oto iashvili  
[optimum.dulopin@laposte.net](mailto:optimum.dulopin@laposte.net)wrote:

> thanks for answer. It seems to be what I need. But Is there a way to  
> optimize or to make kind of inheritance, as all products have some common  
> fields, like price, category, date, images, ...
> 
> On Monday, June 24, 2013 10:22:01 PM UTC+2, Alexander Reelsen wrote:
> 
> > Hey,
> > 
> > simply create different types for each kind of product in one index.  
> > Still your application will need to fire off different kind of searches  
> > depending on the product you are searching for.
> > 
> > Also check out this presentation from Clinton to get up and running  
> > quickly, along with the reference documentation.  
> > [http://www.slideshare.net/\*\*clintongormley/down-and-dirty-](http://www.slideshare.net/**clintongormley/down-and-dirty-)\*\*  
> > with-elasticsearch[http://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch](http://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch)
> > 
> > --Alex
> > 
> > On Mon, Jun 24, 2013 at 9:18 PM, oto iashvili [optimum...@laposte.net](mailto:optimum...@laposte.net)wrote:
> > 
> > > Hi,
> > > 
> > > im trying to use elasticsearch to search through products. If product is  
> > > a car for instance, it will have some field like "color", "brand", "model",  
> > > "km", ...  
> > > If it is clothes, it will only have "color", "size", ...  
> > > I would like to index all this info in elastic to be able then to search  
> > > cars with km between aaa km and bbb km, and / or xxxx model, same for  
> > > clothes or any other products.
> > > 
> > > how can I create such field(s) in elasticsearch ? I want all products to  
> > > be in same index, so user can search through all products, but also if user  
> > > search a type a product, then he should be able to specify some more  
> > > details according to this kind of product.
> > > 
> > > I was thinking about array field, but does that mean that all products  
> > > will have all fields corresponding to all type of products even if some  
> > > fields are not relevant with some products (ie clothes will have km field  
> > > ??) ? Or is it possible on indexing to put just info needed corresponding  
> > > to each product ?
> > > 
> > > thanks
> > > 
> > > --  
> > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![oto\_iashvili](https://avatars.discourse-cdn.com/v4/letter/o/7ba0ec/32.png) [@oto\_iashvili](https://discuss.elastic.co/u/oto_iashvili)\
**Post date:** [June 27, 2013, 1:34pm UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/5 "2013-06-27T13:34:29Z")

</div>

thanks. that is exacty what I was searching.  
On some other forum, someone told me it is also possible to do this by  
creating different types. Do u know if one solution is better (quicklier,  
easyer, ...) that the other ?

On Wednesday, June 26, 2013 8:33:47 AM UTC+2, Alexander Reelsen wrote:

> Hey,
> 
> you can configure a default settings for all types created in your search  
> instance (I am however not a big fan of it, but maybe it helps in your  
> specific usecase). See  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/dynamic-mapping/)
> 
> --Alex
> 
> On Tue, Jun 25, 2013 at 3:14 PM, oto iashvili \<[optimum...@laposte.net](mailto:optimum...@laposte.net)\<javascript:\>
> 
> > wrote:
> 
> > thanks for answer. It seems to be what I need. But Is there a way to  
> > optimize or to make kind of inheritance, as all products have some common  
> > fields, like price, category, date, images, ...
> > 
> > On Monday, June 24, 2013 10:22:01 PM UTC+2, Alexander Reelsen wrote:
> > 
> > > Hey,
> > > 
> > > simply create different types for each kind of product in one index.  
> > > Still your application will need to fire off different kind of searches  
> > > depending on the product you are searching for.
> > > 
> > > Also check out this presentation from Clinton to get up and running  
> > > quickly, along with the reference documentation.  
> > > [http://www.slideshare.net/\*\*clintongormley/down-and-dirty-](http://www.slideshare.net/**clintongormley/down-and-dirty-)\*\*  
> > > with-elasticsearch[http://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch](http://www.slideshare.net/clintongormley/down-and-dirty-with-elasticsearch)
> > > 
> > > --Alex
> > > 
> > > On Mon, Jun 24, 2013 at 9:18 PM, oto iashvili [optimum...@laposte.net](mailto:optimum...@laposte.net)wrote:
> > > 
> > > > Hi,
> > > > 
> > > > im trying to use elasticsearch to search through products. If product  
> > > > is a car for instance, it will have some field like "color", "brand",  
> > > > "model", "km", ...  
> > > > If it is clothes, it will only have "color", "size", ...  
> > > > I would like to index all this info in elastic to be able then to  
> > > > search cars with km between aaa km and bbb km, and / or xxxx model, same  
> > > > for clothes or any other products.
> > > > 
> > > > how can I create such field(s) in elasticsearch ? I want all products  
> > > > to be in same index, so user can search through all products, but also if  
> > > > user search a type a product, then he should be able to specify some more  
> > > > details according to this kind of product.
> > > > 
> > > > I was thinking about array field, but does that mean that all products  
> > > > will have all fields corresponding to all type of products even if some  
> > > > fields are not relevant with some products (ie clothes will have km field  
> > > > ??) ? Or is it possible on indexing to put just info needed corresponding  
> > > > to each product ?
> > > > 
> > > > thanks
> > > > 
> > > > --  
> > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > > .
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:29am UTC](https://discuss.elastic.co/t/different-field-according-to-categories/12529/6 "2017-07-06T02:29:15Z")

</div>


