Error while requesting elasticsearch with a numerical range on a field which doesn't exist

Hello,

I have an error while requesting elasticsearch with a numerical range on a
field which doesn't exist. I expected no error and an empty result, but i
got an error. Is this the expected behaviour ?

Some information about my elasticsearch :
version : 0.19.7
mapping :

$ curl -XGET 'http://localhost:9200/_mapping'

returns : {"twitter":{"user":{"properties":{"name":{"type":"string"}}}}}

This works :
$ curl -X DELETE localhost:9200
$ curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{
"name" : "Shay Banon"
}'
$ curl -XPOST 'http://localhost:9200/_search' -d '{
"from": 0,
"size": 50,
"query": {
"constant_score": {
"filter": {
"query": {
"query_string": {
"default_field": "Date",
"query": "something"
}
}
}
}
}
}'

it returns
: {"took":19,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

But this does not work :

$ curl -X DELETE localhost:9200
$ curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{
"name" : "Shay Banon"
}'
$ curl -XPOST 'http://localhost:9200/_search' -d '{
"from": 0,
"size": 50,
"query": {
"constant_score": {
"filter": {
"numeric_range": {
"Date": {
"gte": "1",
"lte": "2"
}
}
}
}
}
}'

it returns : {"error":"SearchPhaseExecutionException[Failed to execute
phase [query], total failure; shardFailures
{[re38KT1uRm6j1ux0lKzmiQ][twitter][3]: SearchParseException[[twitter][3]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }{[re38KT1uRm6j1ux0lKzmiQ][twitter][2]:
SearchParseException[[twitter][2]: from[0],size[50]: Parse Failure [Failed
to parse source [{\n "from": 0,\n "size": 50,\n "query": {\n
"constant_score": {\n "filter": {\n "numeric_range": {\n
"Date": {\n "gte": "1",\n "lte":
"2"\n }\n }\n }\n }\n }\n}]]]; nested:
QueryParsingException[[twitter] failed to find mapping for field [Date]];
}{[re38KT1uRm6j1ux0lKzmiQ][twitter][1]: SearchParseException[[twitter][1]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }{[re38KT1uRm6j1ux0lKzmiQ][twitter][0]:
SearchParseException[[twitter][0]: from[0],size[50]: Parse Failure [Failed
to parse source [{\n "from": 0,\n "size": 50,\n "query": {\n
"constant_score": {\n "filter": {\n "numeric_range": {\n
"Date": {\n "gte": "1",\n "lte":
"2"\n }\n }\n }\n }\n }\n}]]]; nested:
QueryParsingException[[twitter] failed to find mapping for field [Date]];
}{[re38KT1uRm6j1ux0lKzmiQ][twitter][4]: SearchParseException[[twitter][4]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }]","status":500}

Do you have the same error ? Is this a normal/expected behaviour ? What do
you think could be done to solve this problem ?

Thank you.
Patrick

--

Yes, it's normal.
You would need this log.

In some other request, you need to sure that your index have a specify
field, (eg: sort).

On Tuesday, October 16, 2012 11:01:00 PM UTC+7, Patrick Logan wrote:

Hello,

I have an error while requesting elasticsearch with a numerical range on a
field which doesn't exist. I expected no error and an empty result, but i
got an error. Is this the expected behaviour ?

Some information about my elasticsearch :
version : 0.19.7
mapping :

$ curl -XGET 'http://localhost:9200/_mapping'

returns : {"twitter":{"user":{"properties":{"name":{"type":"string"}}}}}

This works :
$ curl -X DELETE localhost:9200
$ curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{
"name" : "Shay Banon"
}'
$ curl -XPOST 'http://localhost:9200/_search' -d '{
"from": 0,
"size": 50,
"query": {
"constant_score": {
"filter": {
"query": {
"query_string": {
"default_field": "Date",
"query": "something"
}
}
}
}
}
}'

it returns
: {"took":19,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}

But this does not work :

$ curl -X DELETE localhost:9200
$ curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{
"name" : "Shay Banon"
}'
$ curl -XPOST 'http://localhost:9200/_search' -d '{
"from": 0,
"size": 50,
"query": {
"constant_score": {
"filter": {
"numeric_range": {
"Date": {
"gte": "1",
"lte": "2"
}
}
}
}
}
}'

it returns : {"error":"SearchPhaseExecutionException[Failed to execute
phase [query], total failure; shardFailures
{[re38KT1uRm6j1ux0lKzmiQ][twitter][3]: SearchParseException[[twitter][3]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }{[re38KT1uRm6j1ux0lKzmiQ][twitter][2]:
SearchParseException[[twitter][2]: from[0],size[50]: Parse Failure [Failed
to parse source [{\n "from": 0,\n "size": 50,\n "query": {\n
"constant_score": {\n "filter": {\n "numeric_range": {\n
"Date": {\n "gte": "1",\n "lte":
"2"\n }\n }\n }\n }\n }\n}]]]; nested:
QueryParsingException[[twitter] failed to find mapping for field [Date]];
}{[re38KT1uRm6j1ux0lKzmiQ][twitter][1]: SearchParseException[[twitter][1]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }{[re38KT1uRm6j1ux0lKzmiQ][twitter][0]:
SearchParseException[[twitter][0]: from[0],size[50]: Parse Failure [Failed
to parse source [{\n "from": 0,\n "size": 50,\n "query": {\n
"constant_score": {\n "filter": {\n "numeric_range": {\n
"Date": {\n "gte": "1",\n "lte":
"2"\n }\n }\n }\n }\n }\n}]]]; nested:
QueryParsingException[[twitter] failed to find mapping for field [Date]];
}{[re38KT1uRm6j1ux0lKzmiQ][twitter][4]: SearchParseException[[twitter][4]:
from[0],size[50]: Parse Failure [Failed to parse source [{\n "from":
0,\n "size": 50,\n "query": {\n "constant_score": {\n
"filter": {\n "numeric_range": {\n "Date": {\n
"gte": "1",\n "lte": "2"\n }\n }\n
}\n }\n }\n}]]]; nested: QueryParsingException[[twitter] failed to
find mapping for field [Date]]; }]","status":500}

Do you have the same error ? Is this a normal/expected behaviour ? What do
you think could be done to solve this problem ?

Thank you.
Patrick

--