# Suddenly I can't sort on a field in an empty set, ignore\_unmapped not helping

**URL:** <https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895>\
**Category:** Elasticsearch\
**Created:** [August 30, 2012, 2:14pm UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895 "2012-08-30T14:14:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug\_livesey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doug_livesey/32/2114_2.png) [@doug\_livesey](https://discuss.elastic.co/u/doug_livesey)\
**Post date:** [August 30, 2012, 2:14pm UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/1 "2012-08-30T14:14:04Z")

</div>

Hi -- I've had a test suite running just fine for ages, in which a number  
of searches are performed, and return sorted on a listed\_at field.  
I've had to monkey around with some stuff due to Typhoeus changing how it  
handles GET requests (most annoyingly), but the only changes to the queries  
I'm running is that they are POSTs rather than GETs, now. The queries have  
remained the same.  
However, I've now got them all failing with 500s when there are no items to  
search on in the index. This never used to happen, I don't think.  
Anyway, I looked at the documentation again, and saw the bit about  
ignore\_unmapped, and thought I'd try that -- but I still get a failure that  
complains about the field I'm trying to sort on.

An example query looks like this:  
curl -XPOST "[http://localhost:9200/my\_test\_search/items/\_search](http://localhost:9200/my_test_search/items/_search)" -d  
"{"from":0,"size":60,"sort":{"listed\_at":{"order":"desc","ignore\_unmapped":true}},"query":{"term":{"category\_id":1}}}"

And I get this from the body of the 500 response:  
Parse Failure [Failed to parse source  
[{"from":0,"size":60,"sort":{"listed\_at":{"order":"desc","ignore\_unmapped":true}},"query":{"term":{"category\_id":1}}}]]];  
nested: SearchParseException[[my\_test\_search][6]: from[0],size[60]: Parse  
Failure [No mapping found for [listed\_at] in order to sort on]];  
}]","status":500

Could anyone advise me as to what I could look into next? I'm totally  
stumped.  
Cheers,  
Doug.

--

---

<div class="post-metadata">

**Author:** ![doug\_livesey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doug_livesey/32/2114_2.png) [@doug\_livesey](https://discuss.elastic.co/u/doug_livesey)\
**Post date:** [August 31, 2012, 10:04am UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/2 "2012-08-31T10:04:40Z")

</div>

Hi -- updating ES fixed my first issue with this, however I now have a  
similar issue with a faceted search. Unfortunately, it doesn't seem to  
accept "ignore\_unmapped", and explicitly creating the mappings on the index  
doesn't seem to help, either.  
I created the index and the mappings like this:

curl -XPOST "[http://localhost:9200/my\_test\_search](http://localhost:9200/my_test_search)"  
-d "{"mappings":{"items":{"properties":{"listed\_at":{"type":"date"},"price":{"type":"float"},"colour\_ids":{"index\_name":"colour\_id","type":"integer"},"material\_ids":{"index\_name":"material\_id","type":"integer"}}}},"replicas":1}"

To my mind, this should have created the mapping "price" on the items type,  
but apparently not, as running this query:

curl -XPOST "  
[http://localhost:9200/my\_test\_search/items/\_search?pretty=true](http://localhost:9200/my_test_search/items/_search?pretty=true)" -d  
"{"facets":{"facet":{"range":{"field":"price","ranges":[{"to":4.991,"from":0.0},{"to":15.001,"from":5.0},{"to":25.001,"from":15.01},{"to":50.001,"from":25.01},{"to":75.001,"from":50.01},{"to":100.001,"from":75.01},{"from":100.01}],"size":250}}},"size":0,"query":{"term":{"category\_id":1}}}"

Gives me a 500 with this at the end of the voluminous error output:

nested: FacetPhaseExecutionException[Facet [facet]: No mapping found for  
key\_field [price]];

I don't know why this issue suddenly raised it's head, but it's broken all  
my tests, and I'm looking, now, at the  
employee/employer-relationship-straining task of having to rewrite all our  
search code to handle the failures caused by it.  
Can anyone offer any advice at all?  
Cheers,  
Doug.

--

---

<div class="post-metadata">

**Author:** ![doug\_livesey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doug_livesey/32/2114_2.png) [@doug\_livesey](https://discuss.elastic.co/u/doug_livesey)\
**Post date:** [August 31, 2012, 10:13am UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/3 "2012-08-31T10:13:26Z")

</div>

Got it! (Kind of).  
So, I had a query deleting all items before the tests ran, like this:  
put -XDELETE "[http://localhost:9200/folksy\_test\_search/items?q=match\_all](http://localhost:9200/folksy_test_search/items?q=match_all)"

It looks like that was deleting the mappings, too, so I guess I've got the  
match\_all bit of that query wrong?  
It _used_ to send a delete with the query in the body, and that worked  
fine, but I recently updated Typoheus (the old version was being flakey),  
and unfortunately Typhoeus now makes any request with a body into a POST,  
whether you want it to or not (I emphatically don't!).  
So I guess my question now is, how can I delete the items in the index  
without deleting the mappings?  
I'll look into it, later, but in the meantime, this all gives me enough to  
create a work-around that'll let me crack on with other stuff.  
Every day's a schoolday! 🙂  
Cheers,  
Doug.

--

---

<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:** [August 31, 2012, 1:37pm UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/4 "2012-08-31T13:37:17Z")

</div>

Have a look at this:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

[http://www.elasticsearch.org/guide/reference/api/delete-by-query.html](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)

You didn't use \_query endpoint so ES thought you were asking to delete the type  
items  
([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html)  
[http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html](http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html)  
).

HTH  
David.

Le 31 août 2012 à 12:13, doug livesey [biot023@gmail.com](mailto:biot023@gmail.com) a écrit :

> Got it! (Kind of).  
> So, I had a query deleting all items before the tests ran, like this:  
> put -XDELETE " [http://localhost:9200/folksy\_test\_search/items?q=match\_all](http://localhost:9200/folksy_test_search/items?q=match_all)  
> [http://localhost:9200/folksy\_test\_search/items?q=match\_all](http://localhost:9200/folksy_test_search/items?q=match_all) "
> 
> It looks like that was deleting the mappings, too, so I guess I've got the  
> match\_all bit of that query wrong?  
> It _used_ to send a delete with the query in the body, and that worked fine,  
> but I recently updated Typoheus (the old version was being flakey), and  
> unfortunately Typhoeus now makes any request with a body into a POST, whether  
> you want it to or not (I emphatically don't!).  
> So I guess my question now is, how can I delete the items in the index  
> without deleting the mappings?  
> I'll look into it, later, but in the meantime, this all gives me enough to  
> create a work-around that'll let me crack on with other stuff.  
> Every day's a schoolday! 🙂  
> Cheers,  
> Doug.
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![doug\_livesey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/doug_livesey/32/2114_2.png) [@doug\_livesey](https://discuss.elastic.co/u/doug_livesey)\
**Post date:** [August 31, 2012, 2:36pm UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/5 "2012-08-31T14:36:35Z")

</div>

Ah, cheers -- I shall have a play around with that.

On 31 August 2012 14:37, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> \*\*
> 
> Have a look at this:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/delete-by-query.html)
> 
> You didn't use \_query endpoint so ES thought you were asking to delete the  
> type items (  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html)  
> ).
> 
> HTH
> 
> David.
> 
> Le 31 août 2012 à 12:13, doug livesey [biot023@gmail.com](mailto:biot023@gmail.com) a écrit :
> 
> Got it! (Kind of).  
> So, I had a query deleting all items before the tests ran, like this:  
> put -XDELETE "  
> [http://localhost:9200/folksy\_test\_search/items?q=match\_all](http://localhost:9200/folksy_test_search/items?q=match_all)"
> 
> It looks like that was deleting the mappings, too, so I guess I've got  
> the match\_all bit of that query wrong?  
> It _used_ to send a delete with the query in the body, and that worked  
> fine, but I recently updated Typoheus (the old version was being flakey),  
> and unfortunately Typhoeus now makes any request with a body into a POST,  
> whether you want it to or not (I emphatically don't!).  
> So I guess my question now is, how can I delete the items in the index  
> without deleting the mappings?  
> I'll look into it, later, but in the meantime, this all gives me enough  
> to create a work-around that'll let me crack on with other stuff.  
> Every day's a schoolday! 🙂  
> Cheers,  
> Doug.
> 
> --
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> --

--

---

<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:14am UTC](https://discuss.elastic.co/t/suddenly-i-cant-sort-on-a-field-in-an-empty-set-ignore-unmapped-not-helping/8895/6 "2017-07-06T03:14:24Z")

</div>


