# Sort unmapped field

**URL:** <https://discuss.elastic.co/t/sort-unmapped-field/191614>\
**Category:** Elasticsearch\
**Created:** [July 22, 2019, 10:40am UTC](https://discuss.elastic.co/t/sort-unmapped-field/191614 "2019-07-22T10:40:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomsk/32/22061_2.png) [@tomsk](https://discuss.elastic.co/u/tomsk)\
**Post date:** [July 22, 2019, 10:40am UTC](https://discuss.elastic.co/t/sort-unmapped-field/191614/1 "2019-07-22T10:40:49Z")

</div>

Hello, I use this code for sorting products according the price:

```
"sort":[
   { "price": { "order": "desc" } }
]

```

**I know that it doesn't work because field price is unmapped, so it takes probably as "text" so I wonder if I can change query somehow or I have to remove all data, map fields and reindex all data back.**

This is error:

`[Request] ** [http://localhost:9200]-[400] [illegal_argument_exception] Fielddata is disabled on text fields by default. Set fielddata=true on [price] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead., called from sub modified(Search::Elasticsearch::Role::Client::Direct:: __ANON__ ) at (eval 647) line 323. With vars: {'request' => {'body' => ' { "query":{ "constant_score":{ "filter":{ "bool":{ "must":[{ "term":{ "status":"y" } }, { "range":{ "datetime_publish_start":{ "lte":"now/h" } } }], "should":[{ "term": { "cat_path": 3 } }], "must_not":[{ "term":{ "metahash.meta.sold_out":"y" } }] } } } }, "sort":[{ "price": { "order": "desc" } }] } ','path' => '/cyclone3.bellakabelky_sk/a910_product/_search','mime_type' => 'application/json','qs' => {'size' => 61,'from' => 0},'serialize' => 'std','method' => 'GET','ignore' => []},'body' => {'error' => {'phase' => 'query','reason' => 'all shards failed','failed_shards' => [{'shard' => 0,'index' => 'cyclone3.bellakabelky_sk','node' => 'GruggyayQTOMdM0ycEyvIw','reason' => {'type' => 'illegal_argument_exception','reason' => 'Fielddata is disabled on text fields by default. Set fielddata=true on [price] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.'}}],'grouped' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'caused_by' => {'type' => 'illegal_argument_exception','caused_by' => {'type' => 'illegal_argument_exception','reason' => 'Fielddata is disabled on text fields by default. Set fielddata=true on [price] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.'},'reason' => 'Fielddata is disabled on text fields by default. Set fielddata=true on [price] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.'},'root_cause' => [{'reason' => 'Fielddata is disabled on text fields by default. Set fielddata=true on [price] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.','type' => 'illegal_argument_exception'}],'type' => 'search_phase_execution_exception'},'status' => 400},'status_code' => 400}`

---

<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:** [August 19, 2019, 10:40am UTC](https://discuss.elastic.co/t/sort-unmapped-field/191614/2 "2019-08-19T10:40:56Z")

</div>

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