# Which facet need more memory? term facet or range facet?

**URL:** <https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541>\
**Category:** Elasticsearch\
**Created:** [January 29, 2013, 4:03pm UTC](https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541 "2013-01-29T16:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenshin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenshin/32/2508_2.png) [@kenshin](https://discuss.elastic.co/u/kenshin)\
**Post date:** [January 29, 2013, 4:03pm UTC](https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541/1 "2013-01-29T16:03:31Z")

</div>

Hi

I want to implement hierarchical facets for our categories data.  
Categories was stored with nested set model, so every category has a  
`lft` and `rgt` field. I can index these two fields into  
elasticsearch, and use range facet to get count.

Recently I found another way to do the same functionality. Use Path  
Hierarchy Tokenizer which elasticsearch exposed to index category path  
which like /20/134/7856, and use term facet with regex patterns to get  
count.

I'm new to elasticsearch. I have known facets need lots of memory,  
term facet will load relevant field values into memory, but still  
don't know which one is better.

Any suggestion?

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:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [January 30, 2013, 7:36am UTC](https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541/2 "2013-01-30T07:36:38Z")

</div>

Hello,

I'm didn't really understand how your data looks like, but I'd say range  
facets should be faster, because they won't need the regex patterns.

I'd also assume they use less memory, but you can confirm this by testing  
your two implementations, while monitoring your ES cluster.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Tue, Jan 29, 2013 at 6:03 PM, kenshin [himurakenshin54@gmail.com](mailto:himurakenshin54@gmail.com) wrote:

> Hi
> 
> I want to implement hierarchical facets for our categories data.  
> Categories was stored with nested set model, so every category has a  
> `lft` and `rgt` field. I can index these two fields into  
> elasticsearch, and use range facet to get count.
> 
> Recently I found another way to do the same functionality. Use Path  
> Hierarchy Tokenizer which elasticsearch exposed to index category path  
> which like /20/134/7856, and use term facet with regex patterns to get  
> count.
> 
> I'm new to elasticsearch. I have known facets need lots of memory,  
> term facet will load relevant field values into memory, but still  
> don't know which one is better.
> 
> Any suggestion?
> 
> 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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 30, 2013, 10:04am UTC](https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541/3 "2013-01-30T10:04:47Z")

</div>

On Tue, 2013-01-29 at 08:03 -0800, kenshin wrote:

> Hi
> 
> I want to implement hierarchical facets for our categories data.  
> Categories was stored with nested set model, so every category has a  
> `lft` and `rgt` field. I can index these two fields into  
> elasticsearch, and use range facet to get count.
> 
> Recently I found another way to do the same functionality. Use Path  
> Hierarchy Tokenizer which elasticsearch exposed to index category path  
> which like /20/134/7856, and use term facet with regex patterns to get  
> count.
> 
> I'm new to elasticsearch. I have known facets need lots of memory,  
> term facet will load relevant field values into memory, but still  
> don't know which one is better.

I'm unclear as to exactly how you're using the terms/range facets, but  
facets need to load all the field values for every doc into memory.

The memory usage depends on:

1. the number of unique values
2. the number\_of\_docs \* max\_values\_per\_doc

The path hierarchy tokenizer results in multiple values per field,  
eg /foo/bar/baz gives you:

- /foo
- /foo/bar
- /foo/bar/baz  
ie 3 values

clint

--  
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:53am UTC](https://discuss.elastic.co/t/which-facet-need-more-memory-term-facet-or-range-facet/10541/4 "2017-07-06T02:53:58Z")

</div>

Closed on July 6, 2017, 2:53am UTC


