Missing index gives 400 depending on subtle difference in request body

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

POST https://mycluster/myindex/Document/_search?pretty=true&scroll=10m
{
	"size" : 10000,
	"sort" : [{
			"documentId" : {
				"order" : "desc"
			}
		}, {
			"operationtimestamp" : {
				"order" : "desc"
			}
		}
	],
	"_source" : {
		"include" : [
			"operationtimestamp",
			"documentId"
		]
	}
}
{
  "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:

{
	"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.

{
  "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"
}

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