Return multiple values from script engine plugin

ES 6.2.3

My index contains docs like this:
{
str1: "some string",
str2: "other string"
}

I'm using a custom plugin that implements a ScriptEngine based on these examples:
Advanced scripts using script engines
ExplainableScript integration test

I can pass in parameters, compare them to doc values, and return a score.
So far, so good!

Here's the hard part. I need to return more than just the double score. I need to get this information back for each document matched:
{
fuzzyQuality_str1: "high", // or an int or double, doesn't matter
fuzzyQuality_str2: "low", // or an int or double, doesn't matter
composite_score: 42.0
}

I can do the fuzzy computations, and use them to calculate a composite score, and even return that score. I just can't figure out how to also get the "fuzzy quality" values back too.

Is there a way to modify the "hit" somehow?
Or can I return a vector of values?
Some other way?

Unfortunately there is no way to do this. You can, however, use script fields. These would be separate executions (and different scripts), but the script fields will only run on the top N documents, so the overhead should be minimal compared to the cost of scoring millions of documents.

Thank you Ryan - appreciate your quick response.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.