# Missing index gives 400 depending on subtle difference in request body

**URL:** https://discuss.elastic.co/t/missing-index-gives-400-depending-on-subtle-difference-in-request-body/71836
**Category:** Elasticsearch
**Created:** [January 17, 2017, 9:46am UTC](https://discuss.elastic.co/t/missing-index-gives-400-depending-on-subtle-difference-in-request-body/71836 "2017-01-17T09:46:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Dzmitry\_Lahoda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dzmitry_lahoda/32/50591_2.png) [@Dzmitry\_Lahoda](https://discuss.elastic.co/u/Dzmitry_Lahoda)
#### Post date: [January 17, 2017, 9:46am UTC](https://discuss.elastic.co/t/missing-index-gives-400-depending-on-subtle-difference-in-request-body/71836/1 "2017-01-17T09:46:25Z")

</div>

Given I have existing index `myindex` and non existing mapping `Document` next query gives error:

```auto
POST https://mycluster/myindex/Document/_search?pretty=true&scroll=10m

```

```auto
{
	"size" : 10000,
	"sort" : [{
			"documentId" : {
				"order" : "desc"
			}
		}, {
			"operationtimestamp" : {
				"order" : "desc"
			}
		}
	],
	"_source" : {
		"include" : [
			"operationtimestamp",
			"documentId"
		]
	}
}

```

```auto
{
  "error" : {
    "root_cause" : [ {
      "type" : "search_parse_exception",
      "reason" : "No mapping found for [documentId] in order to sort on"
    } ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query_fetch",
    "grouped" : true,
    "failed_shards" : [ {
      "shard" : 0,
      "index" : "myindex",
      "node" : "IsXQzUBeRQeRZCXb9Sqzhw",
      "reason" : {
        "type" : "search_parse_exception",
        "reason" : "No mapping found for [documentId] in order to sort on"
      }
    } ]
  },
  "status" : 400
}

```

, but next query is fine:

```auto
{
	"size" : 10000,
	"_source" : {
		"include" : [
			"operationtimestamp",
			"documentId"
		]
	}
}

```

and return 0 items.

Expected same behavior in both situations or explained why it should different.

I run custom query on many indexes some of which may not be given with data and mapping yet.  
I have not tested query/filter by `documentId` yet.

```auto
{
  "name" : "foobar",
  "cluster_name" : "mycluster",
  "version" : {
    "number" : "2.3.3",
    "build_hash" : "218bdf10790eef486ff2c41a3df5cfa32dadcfde",
    "build_timestamp" : "2016-05-17T15:40:04Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}

```

---

<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: [February 14, 2017, 9:46am UTC](https://discuss.elastic.co/t/missing-index-gives-400-depending-on-subtle-difference-in-request-body/71836/2 "2017-02-14T09:46:31Z")

</div>

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