# Hints for reducing facet memory?

**URL:** https://discuss.elastic.co/t/hints-for-reducing-facet-memory/7423
**Category:** Elasticsearch
**Created:** [April 20, 2012, 4:17pm UTC](https://discuss.elastic.co/t/hints-for-reducing-facet-memory/7423 "2012-04-20T16:17:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Andy\_Wick](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andy_wick/32/44017_2.png) [@Andy\_Wick](https://discuss.elastic.co/u/Andy_Wick)
#### Post date: [April 20, 2012, 4:17pm UTC](https://discuss.elastic.co/t/hints-for-reducing-facet-memory/7423/1 "2012-04-20T16:17:54Z")

</div>

From previous posts I see there might be some help in 0.20 for facet memory  
usage. However I'm hoping there is something I can do myself until then,  
besides add memory/machines. I'm using elasticsearch as a DB so I have  
complete control over my data. I only use facets on a single field (tags)  
that is an array of strings.

```
    "tags": {
      "type": "string",
      "index": "not_analyzed"
    }

```

Would any of the following help  
a) I could have an external lookup table and use an array of ints instead  
of an array of strings. (This would have a side effect of making documents  
smaller too I guess)  
b) Some of the tags are in almost every single document, would it be better  
to switch those out to a separate fields that are indexed instead of using  
facets?  
c) reduce the number of replicas (are they each loading things into memory?)  
d) Use more or less shards (right now 60 across 10 machines)  
e) anything else? 🙂

Thanks,  
Andy

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [April 21, 2012, 3:11pm UTC](https://discuss.elastic.co/t/hints-for-reducing-facet-memory/7423/2 "2012-04-21T15:11:01Z")

</div>

Moving to use ints for tags instead of the full string representation will  
help a lot memory wise, and reducing the number of shards will also help.

On Fri, Apr 20, 2012 at 7:17 PM, Andy Wick [andywick@gmail.com](mailto:andywick@gmail.com) wrote:

> From previous posts I see there might be some help in 0.20 for facet  
> memory usage. However I'm hoping there is something I can do myself until  
> then, besides add memory/machines. I'm using elasticsearch as a DB so I  
> have complete control over my data. I only use facets on a single field  
> (tags) that is an array of strings.
> 
> ```
> "tags": {
> "type": "string",
> "index": "not_analyzed"
> }
> 
> ```
> 
> Would any of the following help  
> a) I could have an external lookup table and use an array of ints instead  
> of an array of strings. (This would have a side effect of making documents  
> smaller too I guess)  
> b) Some of the tags are in almost every single document, would it be  
> better to switch those out to a separate fields that are indexed instead of  
> using facets?  
> c) reduce the number of replicas (are they each loading things into  
> memory?)  
> d) Use more or less shards (right now 60 across 10 machines)  
> e) anything else? 🙂
> 
> Thanks,  
> Andy

---

<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, 3:31am UTC](https://discuss.elastic.co/t/hints-for-reducing-facet-memory/7423/3 "2017-07-06T03:31:28Z")

</div>


