Scripting exception


(yingsun cheng) #1

Hi,
Can anybody help me? When I'm using "script" in my search query,
there are some excetions happens:
========== Request ===============
curl -XGET 'http://localhost:9200/twitter/user/_search?
pretty=true' -d '
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "doc['age'].value > 20"
}
}
}
}
}'
=========== Response ===============
{
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "twitter",
"shard" : 4,
"reason" : "QueryPhaseExecutionException[[twitter][4]:
query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAllDocsFilter@aecd51))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]];
"
}, {
"index" : "twitter",
"shard" : 2,
"reason" : "QueryPhaseExecutionException[[twitter][2]:
query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAllDocsFilter@aecd51))-
ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
=========== Type Mapping ===================
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"passwd": {
"type": "string",
"index": "no"
},
"sex": {
"type": "boolean",
"index": "yes",
"null_value" : "no"
},
"age": {
"type": "integer",
"index": "yes",
"null_value" : 0
},
"email": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}


(Shay Banon) #2

Can you gist a curl recreation with setting up the data (and mappings)?

On Mon, Nov 1, 2010 at 10:09 AM, yingsun cheng xingrongcheng@gmail.comwrote:

Hi,
Can anybody help me? When I'm using "script" in my search query,
there are some excetions happens:
========== Request ===============
curl -XGET 'http://localhost:9200/twitter/user/_search?
pretty=true' -d '
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "doc['age'].value > 20"
}
}
}
}
}'
=========== Response ===============
{
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "twitter",
"shard" : 4,
"reason" : "QueryPhaseExecutionException[[twitter][4]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAllDocsFilter@aecd51
))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]];
"
}, {
"index" : "twitter",
"shard" : 2,
"reason" : "QueryPhaseExecutionException[[twitter][2]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAllDocsFilter@aecd51
))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
=========== Type Mapping ===================
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"passwd": {
"type": "string",
"index": "no"
},
"sex": {
"type": "boolean",
"index": "yes",
"null_value" : "no"
},
"age": {
"type": "integer",
"index": "yes",
"null_value" : 0
},
"email": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}


(yingsun cheng) #3

// Using elasticsearch-0.12.1
// Creat Index:
curl -XPUT 'http://localhost:9200/twitter/'

// Put Mapping
curl -XPUT 'http://localhost:9200/twitter/user/_mapping' -d '
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"age": {
"type": "integer",
"null_value" : 0
}
}
}
}'

// Index
curl -XPOST 'http://localhost:9200/twitter/user/' -d '
{
"name": "amdin",
"age": 25
}'

// Search with Script
curl -XGET 'http://localhost:9200/twitter/user/_search?pretty=true' -d
'
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc['age'].value > 25"
}
}
}
}
}'

// Then get Excetion
.....

On 11月1日, 下午9时11分, Shay Banon shay.ba...@elasticsearch.com wrote:

Can you gist a curl recreation with setting up the data (and mappings)?

On Mon, Nov 1, 2010 at 10:09 AM, yingsun cheng xingrongch...@gmail.comwrote:

Hi,
Can anybody help me? When I'm using "script" in my search query,
there are some excetions happens:
========== Request ===============
curl -XGET 'http://localhost:9200/twitter/user/_search?
pretty=true' -d '
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "doc['age'].value > 20"
}
}
}
}
}'
=========== Response ===============
{
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "twitter",
"shard" : 4,
"reason" : "QueryPhaseExecutionException[[twitter][4]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl lDocsFilter@aecd51
))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]];
"
}, {
"index" : "twitter",
"shard" : 2,
"reason" : "QueryPhaseExecutionException[[twitter][2]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl lDocsFilter@aecd51
))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
=========== Type Mapping ===================
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"passwd": {
"type": "string",
"index": "no"
},
"sex": {
"type": "boolean",
"index": "yes",
"null_value" : "no"
},
"age": {
"type": "integer",
"index": "yes",
"null_value" : 0
},
"email": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}


(Shay Banon) #4

Hi,

It seems like its a problem with curl and using the ' sign. Its used
around age, and to denote the HTTP body for curl, Try this one:

curl -XGET 'http://localhost:9200/twitter/user/_search?pretty=true' -d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc["age"].value == 25"
}
}
}
}
}'

2010/11/2 yingsun cheng xingrongcheng@gmail.com

// Using elasticsearch-0.12.1
// Creat Index:
curl -XPUT 'http://localhost:9200/twitter/'

// Put Mapping
curl -XPUT 'http://localhost:9200/twitter/user/_mapping' -d '
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"age": {
"type": "integer",
"null_value" : 0
}
}
}
}'

// Index
curl -XPOST 'http://localhost:9200/twitter/user/' -d '
{
"name": "amdin",
"age": 25
}'

// Search with Script
curl -XGET 'http://localhost:9200/twitter/user/_search?pretty=true' -d
'
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc['age'].value > 25"
}
}
}
}
}'

// Then get Excetion
.....

On 11月1日, 下午9时11分, Shay Banon shay.ba...@elasticsearch.com wrote:

Can you gist a curl recreation with setting up the data (and mappings)?

On Mon, Nov 1, 2010 at 10:09 AM, yingsun cheng <xingrongch...@gmail.com
wrote:

Hi,
Can anybody help me? When I'm using "script" in my search query,
there are some excetions happens:
========== Request ===============
curl -XGET 'http://localhost:9200/twitter/user/_search?
pretty=true' -d '
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "doc['age'].value > 20"
}
}
}
}
}'
=========== Response ===============
{
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "twitter",
"shard" : 4,
"reason" : "QueryPhaseExecutionException[[twitter][4]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl
lDocsFilter@aecd51

))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]];
"
}, {
"index" : "twitter",
"shard" : 2,
"reason" : "QueryPhaseExecutionException[[twitter][2]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl
lDocsFilter@aecd51

))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
=========== Type Mapping ===================
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"passwd": {
"type": "string",
"index": "no"
},
"sex": {
"type": "boolean",
"index": "yes",
"null_value" : "no"
},
"age": {
"type": "integer",
"index": "yes",
"null_value" : 0
},
"email": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}


(yingsun cheng) #5

It works. Thank you!

On 11月2日, 下午4时26分, Shay Banon shay.ba...@elasticsearch.com wrote:

Hi,

It seems like its a problem with curl and using the ' sign. Its used
around age, and to denote the HTTP body for curl, Try this one:

curl -XGET 'http://localhost:9200/twitter/user/_search?pretty=true'-d '
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc["age"].value == 25"
}
}
}
}

}'

2010/11/2 yingsun cheng xingrongch...@gmail.com

// Using elasticsearch-0.12.1
// Creat Index:
curl -XPUT 'http://localhost:9200/twitter/'

// Put Mapping
curl -XPUT 'http://localhost:9200/twitter/user/_mapping'-d '
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"age": {
"type": "integer",
"null_value" : 0
}
}
}
}'

// Index
curl -XPOST 'http://localhost:9200/twitter/user/'-d '
{
"name": "amdin",
"age": 25
}'

// Search with Script
curl -XGET 'http://localhost:9200/twitter/user/_search?pretty=true'-d
'
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"script": {
"script": "doc['age'].value > 25"
}
}
}
}
}'

// Then get Excetion
.....

On 11月1日, 下午9时11分, Shay Banon shay.ba...@elasticsearch.com wrote:

Can you gist a curl recreation with setting up the data (and mappings)?

On Mon, Nov 1, 2010 at 10:09 AM, yingsun cheng <xingrongch...@gmail.com
wrote:

Hi,
Can anybody help me? When I'm using "script" in my search query,
there are some excetions happens:
========== Request ===============
curl -XGET 'http://localhost:9200/twitter/user/_search?
pretty=true' -d '
{
"query" : {
"filtered" : {
"query" : {
"match_all": {}
},
"filter" : {
"script" : {
"script" : "doc['age'].value > 20"
}
}
}
}
}'
=========== Response ===============
{
"_shards" : {
"total" : 5,
"successful" : 3,
"failed" : 2,
"failures" : [ {
"index" : "twitter",
"shard" : 4,
"reason" : "QueryPhaseExecutionException[[twitter][4]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl
lDocsFilter@aecd51

))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@17fdc2d]];
"
}, {
"index" : "twitter",
"shard" : 2,
"reason" : "QueryPhaseExecutionException[[twitter][2]:

query[filtered(ConstantScore(org.elasticsearch.common.lucene.search.MatchAl
lDocsFilter@aecd51

))-

ScriptFilter(doc[age].value > 20)],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested: CompileException[[Error: No
field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
nested: ElasticSearchIllegalArgumentException[No field found for
[org.elasticsearch.index.field.data.longs.LongDocFieldData@19f5d89]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
=========== Type Mapping ===================
{
"user": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
},
"passwd": {
"type": "string",
"index": "no"
},
"sex": {
"type": "boolean",
"index": "yes",
"null_value" : "no"
},
"age": {
"type": "integer",
"index": "yes",
"null_value" : 0
},
"email": {
"type": "string"
},
"address": {
"type": "string"
}
}
}
}


(system) #6