# Solutions for when a sort field doesn't exist in the mapping

**URL:** <https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122>\
**Category:** Elasticsearch\
**Created:** [December 10, 2011, 6:41pm UTC](https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122 "2011-12-10T18:41:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [December 10, 2011, 6:41pm UTC](https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122/1 "2011-12-10T18:41:43Z")

</div>

Hiya,

When a field cannot be found in the mapping during the sort operation,  
is there a way to have the system not throw an exception? It would be  
nice if the field at fault is ignored from the sort fields.

Is the only other option to: pull the mappings for the item in the  
particular index, see if the field exists or not, then tailor the  
search statement?

Thank you for your time,  
Bryan Green

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [December 10, 2011, 6:49pm UTC](https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122/2 "2011-12-10T18:49:18Z")

</div>

Sorry to reply to my own post...

I can turn down the log4j level from DEBUG to WARN as a "solution" but  
I'd like to see if I can have this cleaned up via elasticsearch and  
not have to make additional calls from my end.

Have a great weekend.  
Bryan

On Dec 10, 12:41 pm, Bryan Green [bryogr...@gmail.com](mailto:bryogr...@gmail.com) wrote:

> Hiya,
> 
> When a field cannot be found in the mapping during the sort operation,  
> is there a way to have the system not throw an exception? It would be  
> nice if the field at fault is ignored from the sort fields.
> 
> Is the only other option to: pull the mappings for the item in the  
> particular index, see if the field exists or not, then tailor the  
> search statement?
> 
> Thank you for your time,  
> Bryan Green

---

<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:** [December 12, 2011, 12:49pm UTC](https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122/3 "2011-12-12T12:49:45Z")

</div>

Tuning the logging won't help, since it still won't search on those shards  
/ indices where that field does not exists. It might be possible (might get  
tricky when doing the "reduce" part of the search) to ignore fields that do  
not exists, but open an issue, it might be possible.

On Sat, Dec 10, 2011 at 8:49 PM, Bryan Green [bryogreen@gmail.com](mailto:bryogreen@gmail.com) wrote:

> Sorry to reply to my own post...
> 
> I can turn down the log4j level from DEBUG to WARN as a "solution" but  
> I'd like to see if I can have this cleaned up via elasticsearch and  
> not have to make additional calls from my end.
> 
> Have a great weekend.  
> Bryan
> 
> On Dec 10, 12:41 pm, Bryan Green [bryogr...@gmail.com](mailto:bryogr...@gmail.com) wrote:
> 
> > Hiya,
> > 
> > When a field cannot be found in the mapping during the sort operation,  
> > is there a way to have the system not throw an exception? It would be  
> > nice if the field at fault is ignored from the sort fields.
> > 
> > Is the only other option to: pull the mappings for the item in the  
> > particular index, see if the field exists or not, then tailor the  
> > search statement?
> > 
> > Thank you for your time,  
> > Bryan Green

---

<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:45am UTC](https://discuss.elastic.co/t/solutions-for-when-a-sort-field-doesnt-exist-in-the-mapping/6122/4 "2017-07-06T03:45:42Z")

</div>


