# Creating my own binary sorting collation, how to store in Elastic?

**URL:** <https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860>\
**Category:** Elasticsearch\
**Created:** [April 7, 2020, 9:32am UTC](https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860 "2020-04-07T09:32:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JJK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jjk/32/26684_2.png) [@JJK](https://discuss.elastic.co/u/JJK)\
**Post date:** [April 7, 2020, 9:32am UTC](https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860/1 "2020-04-07T09:32:40Z")

</div>

I have my own binary fields that store a sorting collation in my current database.  
These are created with some very specific rules.

I'd like to store these in Elastic and have Elastic sort by that field.  
But it appears that the binary field type gets stored as base64, which screws up the sort order.

What is the best way to store this binary data and sort in Elastic?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 7, 2020, 9:44am UTC](https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860/2 "2020-04-07T09:44:34Z")

</div>

But how do you sort binary content?  
I mean that I can't see any solution but implementing your own plugin which could do that.

What kind of binary content is that? Could you extract some textual information from it or numbers or anything that could help sorting?

---

<div class="post-metadata">

**Author:** ![JJK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jjk/32/26684_2.png) [@JJK](https://discuss.elastic.co/u/JJK)\
**Post date:** [April 8, 2020, 3:37am UTC](https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860/3 "2020-04-08T03:37:53Z")

</div>

Nvm, figured out that converting binary to hex gives me the results I need.  
Cheers!

---

<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:** [May 6, 2020, 3:37am UTC](https://discuss.elastic.co/t/creating-my-own-binary-sorting-collation-how-to-store-in-elastic/226860/4 "2020-05-06T03:37:59Z")

</div>

Closed on May 6, 2020, 3:37am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
