# IDF per category

**URL:** <https://discuss.elastic.co/t/idf-per-category/19575>\
**Category:** Elasticsearch\
**Created:** [September 2, 2014, 3:06pm UTC](https://discuss.elastic.co/t/idf-per-category/19575 "2014-09-02T15:06:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicom/32/488_2.png) [@nicom](https://discuss.elastic.co/u/nicom)\
**Post date:** [September 2, 2014, 3:06pm UTC](https://discuss.elastic.co/t/idf-per-category/19575/1 "2014-09-02T15:06:56Z")

</div>

I have a set of categories containing some products

I would like to index the label and the category of the products (to handle  
record linkage).

the issues is: some terms are common for some categories but could be  
discrimant for other categories.

So I would like to compute the IDF of a word not for all the products but  
per category.

How to handle that?

1. creating several indexes? one per category

2. or creating several objects inside an index ? one per category

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 2, 2014, 4:47pm UTC](https://discuss.elastic.co/t/idf-per-category/19575/2 "2014-09-02T16:47:45Z")

</div>

Hello ,

You can do a 2 level aggregation term query with first level as category  
and second level as the content.

{  
"aggregations": {  
"categories": {  
"terms": {  
"field": "category"  
},  
"aggregations": {  
"categories": {  
"terms": {  
"field": "content"  
}  
}  
}  
}  
}  
}

Aggregations -

> **[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.

Terms aggregation -

> **[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.

Thanks  
Vineeth

On Tue, Sep 2, 2014 at 8:36 PM, NM [n.maisonneuve@gmail.com](mailto:n.maisonneuve@gmail.com) wrote:

> I have a set of categories containing some products
> 
> I would like to index the label and the category of the products (to  
> handle record linkage).
> 
> the issues is: some terms are common for some categories but could be  
> discrimant for other categories.
> 
> So I would like to compute the IDF of a word not for all the products but  
> per category.
> 
> How to handle that?
> 
> 1. creating several indexes? one per category
> 
> 2. or creating several objects inside an index ? one per category
> 
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e6b06ff9-e4ca-4ab9-a0e8-885eb93a94ea%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5%3DZ0dFnmQND3s%2BrFUMLMf7mNToFEqhDeW4Sw1KzTRjwsQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DZ0dFnmQND3s%2BrFUMLMf7mNToFEqhDeW4Sw1KzTRjwsQ%40mail.gmail.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:04am UTC](https://discuss.elastic.co/t/idf-per-category/19575/3 "2017-07-06T01:04:56Z")

</div>

Closed on July 6, 2017, 1:04am UTC


