# Can \_search\_with\_cluster also cluster the result if content is of type "attachment"?

**URL:** <https://discuss.elastic.co/t/can--search-with-cluster-also-cluster-the-result-if-content-is-of-type-attachment/17635>\
**Category:** Elasticsearch\
**Created:** [May 21, 2014, 5:02am UTC](https://discuss.elastic.co/t/can--search-with-cluster-also-cluster-the-result-if-content-is-of-type-attachment/17635 "2014-05-21T05:02:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratikshya\_Kuinkel](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@Pratikshya\_Kuinkel](https://discuss.elastic.co/u/Pratikshya_Kuinkel)\
**Post date:** [May 21, 2014, 5:02am UTC](https://discuss.elastic.co/t/can--search-with-cluster-also-cluster-the-result-if-content-is-of-type-attachment/17635/1 "2014-05-21T05:02:56Z")

</div>

You won't be able to cluster the base64 encoded string directly. But, if you specify "fields" when firing your query, you will be able to do that. Please have a look at the following gist:

> <https://gist.github.com/anonymous/0e75d85d3a8e97c95f63>

  
You will now be able to use files.file when clustering your result. However, if you have an array of attachments, it will treat all the files as a single file when clustering. Only way we can access them as array is through \_source, which again will only return base64 encoded string. Not sure how to get around this issue. But for single files, using "field\_mapping": { "title":[fields.files.file"]} should work. Let me know how it goes.

--  
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/8EFF6C0A-4E11-442D-9449-4FEED27A2739%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/8EFF6C0A-4E11-442D-9449-4FEED27A2739%40gmail.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:28am UTC](https://discuss.elastic.co/t/can--search-with-cluster-also-cluster-the-result-if-content-is-of-type-attachment/17635/2 "2017-07-06T01:28:00Z")

</div>

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


