# Sorting by aliased (with index\_name) non-analyzed fields

**URL:** <https://discuss.elastic.co/t/sorting-by-aliased-with-index-name-non-analyzed-fields/17239>\
**Category:** Elasticsearch\
**Created:** [April 28, 2014, 3:34pm UTC](https://discuss.elastic.co/t/sorting-by-aliased-with-index-name-non-analyzed-fields/17239 "2014-04-28T15:34:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plamen\_Mishev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/plamen_mishev/32/1608_2.png) [@Plamen\_Mishev](https://discuss.elastic.co/u/Plamen_Mishev)\
**Post date:** [April 28, 2014, 3:34pm UTC](https://discuss.elastic.co/t/sorting-by-aliased-with-index-name-non-analyzed-fields/17239/1 "2014-04-28T15:34:32Z")

</div>

I'm searching in two separate indexes with two separate types at once.

In index1, I have a field 'work\_email'.  
In index2, I have a field 'email'.

I need to sort all results by email.

For this purpose I looked into using the 'index\_name' property of ES, so  
the 'work\_email' field can be referenced as 'email' too.  
On the other hand, in order to get proper the results in the proper order,  
I must sort on non-analyzed values, which is why I upgraded my fields to  
multi\_fields.  
The problem is that there doesn't seem to be a way to reference the  
work\_email.raw field as email.raw.

You can see my recreation gist here:

> <https://gist.github.com/pmishev/11375297>

I looked into using 'copy\_to' as well, but couldn't figure out a way with  
it either.

To sum up: How can I order on non-analyzed field, which is aliased?

Running on:  
"version": {  
"number": "1.1.1",  
"build\_hash": "f1585f096d3f3985e73456debdc1a0745f512bbc",  
"build\_timestamp": "2014-04-16T14:27:12Z",  
"build\_snapshot": false,  
"lucene\_version": "4.7"  
},

--  
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/2b68a7af-cc9e-4e79-96f1-40aa9e71fc6c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2b68a7af-cc9e-4e79-96f1-40aa9e71fc6c%40googlegroups.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:33am UTC](https://discuss.elastic.co/t/sorting-by-aliased-with-index-name-non-analyzed-fields/17239/2 "2017-07-06T01:33:03Z")

</div>


