# Slow attachment autocompletion with edge-ngrams and highlighting

**URL:** <https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180>\
**Category:** Elasticsearch\
**Created:** [September 21, 2016, 8:50pm UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180 "2016-09-21T20:50:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kzal/32/12068_2.png) [@kzal](https://discuss.elastic.co/u/kzal)\
**Post date:** [September 21, 2016, 8:50pm UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/1 "2016-09-21T20:50:30Z")

</div>

Hi,  
I have a problem with slow performance when querying (term) an index with 10GB of attachments and using highlighting. The highlighting slows it down about 3-4x. I'm using edge-ngram tokenizer when indexing (min-gram-3, max-gram-15.  
Is there an approach to speed things up??

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 22, 2016, 10:36am UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/2 "2016-09-22T10:36:52Z")

</div>

I expect the trouble with highlighting is that it wants to load the body of the document and to do that it has to unzip the 10GB attachment which is huge. Then it has to convert it to a `Map` so we can get the part we want out of the source. Disaster!

So you have two options I think. Have a look at the completion suggester - it is designed to return the term that it suggests without having to go to the document. OTOH it has to build the FST it uses to suggest to you in Java's **heap** so it has quite a bit of overhead. It still might be the best way.

Another option is to use the term suggester somehow though I'm not sure how - you'd have to experiment with it quite a lot. It doesn't reach into the source at all.

---

<div class="post-metadata">

**Author:** ![kzal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kzal/32/12068_2.png) [@kzal](https://discuss.elastic.co/u/kzal)\
**Post date:** [September 22, 2016, 11:00am UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/3 "2016-09-22T11:00:14Z")

</div>

The problem is, the content of attachments is encoded base64, so I have no idea, how to use it with suggestions. What's more, the river (the mongodb river) prevents me from playing with index mapping very much.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 22, 2016, 8:42pm UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/4 "2016-09-22T20:42:20Z")

</div>

If you aren't using the content then why highlight it?

Also, rivers have been deprecated for a long time. I suspect you are using a super old version then. So upgrading _might_ help some.

---

<div class="post-metadata">

**Author:** ![kzal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kzal/32/12068_2.png) [@kzal](https://discuss.elastic.co/u/kzal)\
**Post date:** [September 23, 2016, 3:14pm UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/5 "2016-09-23T15:14:30Z")

</div>

I'm using it to extract autocompletion phrases, using n-grams, but suggesters require special mapping (i.e. 'type':'suggestion').

---

<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 5, 2017, 10:17pm UTC](https://discuss.elastic.co/t/slow-attachment-autocompletion-with-edge-ngrams-and-highlighting/61180/6 "2017-07-05T22:17:39Z")

</div>


