I am trying to upgrade a plugin from 1.* to 5.*
Maybe I am doing something wrong here, but this used to work in 1.*.
We have a script plugin that pulls in results from a different type (child documents), caches them, and returns child document data. There are additional scripts that use the same cached data for range filters or other things on child data.
It would be called like this, for example:
"script_fields": {
"price": {
"script": {
"params": {
"profileId": 4766,
"index": "icommon",
"missingValue": 0
},
"lang": "native",
"inline": "get_price"
}
}
}
Previously, we had access to the search context in the NativeScriptFactory:
@Override
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
final SearchContext searchContext = SearchContext.current();
...
searchContext.searcher().search(new MatchAllDocsQuery(), f, new Collector() {
...
}
However, current()
was removed here https://github.com/elastic/elasticsearch/commit/9c9afe3f01cf418cf983b4ef1c031f34a728bb12
I have tried using the PreBuiltTransportClient
and passing into the factory, but this requires additional dependencies (I don't think this is the correct approach).
Is searching within a plugin just not supported anymore, or am I missing something?