hi all,
as already discussed on irc, i don't know how to check for the
existence of a field in a script filter. version 0.14.1 and 0.14.2
tried
note that this example is not the full implementation and i know that
this can be done without script it is just for demonstration.
so when i issue:
curl -XPUT $H/ft/Policy/1 -d '
{
"contract": "blah",
constraints:[
{
"regions": "reg1",
"applications": "app1"
},
{
"regions": "any",
"applications": "app2"
}
]
}
'
curl -XGET $H/ft/Policy/_search?pretty=1 -d '
{
"query": {
"filtered" : {
"query" : {match_all:{}},
"filter" : {
"script" : {
"script" : "_source.contains_key('x')"
,
"params" : {"a" : "app1", "r": "at"}
}
}
}
}
}
'
i get:
{
"took" : 87,
"_shards" : {
"total" : 5,
"successful" : 4,
"failed" : 1,
"failures" : [ {
"index" : "ft",
"shard" : 2,
"reason" : "RemoteTransportException[[Harmonica][inet[/
192.168.34.135:9300]][search/phase/query]]; nested:
QueryPhaseExecutionException[[ft][2]:
query[filtered(ConstantScore(:))-
ScriptFilter(_source.contains_key(x))],from[0],size[10]: Query Failed
[Failed to execute main query]]; nested:
PropertyAccessException[[Error: could not access: x; in class: null]
\n[Near : {... Unknown ....}]\n ^\n[Line: 1, Column: 0]];
"
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}
is there another way? imho "containsKey" sounds like it should return
a boolean
thx in advance, bernd