Empty source in script plugin used on nested field


#1

I don't get any results for queries using plugin script filter over nested fields, even though the script does work as expected for non nested fields. The reason, as I observed while debugging my script is that I fetch source() in the script which tends to be empty when I keep my script inside nested, but returns one document per successive call when querying over non nested fields.

My guess is that it has to do with nested fields having their own separate document, and the docId provided for the document when used to fetch source can not be fetched from inside nested field?

Mapping:
properties = {
address = {
type=nested,
properties= {
street= {
type=string,
fielddata= {
format=disabled
}
},
zip= {
type=long
}
}
},
age= {
type=long
},
designation= {
type=string,
fielddata= {
format=disabled
}
},
eventTimestamp= {
type=date,
format=strict_date_optional_time||epoch_millis
},
pickupTimestamp= {
type=date,
format=strict_date_optional_time||epoch_millis
},
user= {
type=string,
index=not_analyzed
}
}
}

Query:

{
"size" : 10000,
"timeout" : 30000,
"query" : {
"bool" : {
"must" : [ {
"match_all" : { }
}, {
"nested" : {
"query" : {
"script" : {
"script" : {
"inline" : "WildcardFilterScript",
"lang" : "native",
"params" : {
"params" : "eyJmaWVsZF9uYW1lIjoiYWRkcmVzcy5zdHJlZXQiLCJxdWVyeV9zdHJpbmciOiIqUyoifQ=="
}
}
}
},
"path" : "address"
}
} ]
}
},
"sort" : [ {
"eventTimestamp" : {
"order" : "desc"
}
} ]
}


(system) #2