All Products
Search
Document Center

OpenSearch:OpsDoc

Last Updated:Apr 01, 2026

OpsDoc is a Cava framework class that gives sort plugins access to document fields and variables during score calculation. The system creates OpsDoc objects automatically — retrieve one by calling params.getDoc() in either the init or score function of your sort plugin.

Capabilities:

  • Read attribute field values from the current document (scalar and array types)

  • Declare and exchange variables across multiple plugins

  • Emit trace output for debugging score logic on the Search Test page

Important

OpsDoc can only read attribute fields that are configured in the OpenSearch console and declared via requireAttribute in the init function. Fields not declared during initialization cannot be retrieved correctly at scoring time.

Functions

Field access

SignatureField typeReturns
boolean requireAttribute(CString fieldName)true if declared; false otherwise
long docFieldLong(CString fieldName)INTlong
float docFieldFloat(CString fieldName)FLOATfloat
double docFieldDouble(CString fieldName)DOUBLEdouble
CString docFieldLiteral(CString fieldName)LITERALCString
long[] docFieldLongArray(CString fieldName)INT_ARRAYlong[], or null on failure
float[] docFieldFloatArray(CString fieldName)FLOAT_ARRAYfloat[], or null on failure
double[] docFieldDoubleArray(CString fieldName)DOUBLE_ARRAYdouble[], or null on failure
CString[] docFieldLiteralArray(CString fieldName)LITERAL_ARRAYCString[], or null on failure
OpsGeoPoint docFieldGeoPoint(CString fieldName)GEO_POINTOpsGeoPoint, or null on failure
OpsTimestamp docFieldTimestamp(CString fieldName)TIMESTAMPOpsTimestamp, or null on failure

Variable management

SignaturePhaseDescription
boolean declareLongVariable(CString variableName, boolean needSerialize)init onlyDeclares a LONG variable
boolean declareDoubleVariable(CString variableName, boolean needSerialize)init onlyDeclares a DOUBLE variable
void setLongVariable(CString variableName, long value)score onlySets a LONG variable value
void setDoubleVariable(CString variableName, long value)score onlySets a DOUBLE variable value
long getLongVariable(CString variableName)score onlyGets a LONG variable value
double getDoubleVariable(CString variableName)score onlyGets a DOUBLE variable value

Trace

All trace overloads are available in both single-value and prefixed forms. See Trace functions for details and constraints.

Signature
void trace(byte value)
void trace(CString prefix, byte value)
void trace(short value)
void trace(CString prefix, short value)
void trace(int value)
void trace(CString prefix, int value)
void trace(long value)
void trace(CString prefix, long value)
void trace(float value)
void trace(CString prefix, float value)
void trace(double value)
void trace(CString prefix, double value)
void trace(CString value)
void trace(CString prefix, CString value)

Function details

requireAttribute

boolean requireAttribute(CString fieldName)

Declares an attribute field for use during score calculation. Call this in the init function — fields not declared here cannot be read correctly in the score function.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: true if declared successfully. false in most cases means the field is not configured as an attribute field in the OpenSearch console.

requireAttribute can only be called during initialization (init).

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        CString field1;
        boolean ret = params.getDoc().requireAttribute(field1); // field1 must be a constant
        ret = params.getDoc().requireAttribute("price");
        return ret;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float floatValue = doc.docFieldFloat("price");
        return floatValue;
    }
}

docFieldLong

long docFieldLong(CString fieldName)

Gets the value of an INT-type attribute field as a long.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as a long.

If the field is FLOAT or DOUBLE type, the value is rounded to the nearest integer. If the field is LITERAL or ARRAY type, 0 is returned.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("count");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        long count = doc.docFieldLong("count");
        return (double)count;
    }
}

docFieldFloat

float docFieldFloat(CString fieldName)

Gets the value of a FLOAT-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as a float.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("count");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float count = doc.docFieldFloat("count");
        return (double)count;
    }
}

docFieldDouble

double docFieldDouble(CString fieldName)

Gets the value of a DOUBLE-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as a double.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("count");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        double count = doc.docFieldDouble("count");
        return count;
    }
}

docFieldLiteral

CString docFieldLiteral(CString fieldName)

Gets the value of a LITERAL-type attribute field as a CString.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as a CString.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("tag");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        CString tag = doc.docFieldLiteral("tag");
        if (tag.equals("abc")) {
            return 100.0;
        }
        return 0;
    }
}

docFieldLongArray

long[] docFieldLongArray(CString fieldName)

Gets the value of an INT_ARRAY-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as long[].

Returns null if the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check for null before accessing elements.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("tags");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        long[] tags = doc.docFieldLongArray("tags");
        if (tags != null) {
            if (tags.length > 0) {
                return (double)tags[0];
            }
        }
        return 0;
    }
}

docFieldFloatArray

float[] docFieldFloatArray(CString fieldName)

Gets the value of a FLOAT_ARRAY-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as float[].

Returns null if the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check for null before accessing elements.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("tags");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float[] tags = doc.docFieldFloatArray("tags");
        if (tags != null) {
            if (tags.length > 0) {
                return (double)tags[0];
            }
        }
        return 0;
    }
}

docFieldDoubleArray

double[] docFieldDoubleArray(CString fieldName)

Gets the value of a DOUBLE_ARRAY-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as double[].

Returns null if the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check for null before accessing elements.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("tags");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        double[] tags = doc.docFieldDoubleArray("tags");
        if (tags != null) {
            if (tags.length > 0) {
                return (double)tags[0];
            }
        }
        return 0;
    }
}

docFieldLiteralArray

CString[] docFieldLiteralArray(CString fieldName)

Gets the value of a LITERAL_ARRAY-type attribute field.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: The field value as CString[].

Returns null if the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check for null before accessing elements.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("tags");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        CString[] tags = doc.docFieldLiteralArray("tags");
        if (tags != null) {
            if (tags.length > 0 && tags[0].equals("abc")) {
                return 100.0;
            }
        }
        return 0;
    }
}

docFieldGeoPoint

OpsGeoPoint docFieldGeoPoint(CString fieldName)

Gets the value of a GEO_POINT-type attribute field as an OpsGeoPoint object.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: An OpsGeoPoint object.

Returns null if the field does not exist or the field type is invalid. Import com.aliyun.opensearch.cava.framework.OpsGeoPoint before using this function.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;
import com.aliyun.opensearch.cava.framework.OpsGeoPoint;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("location");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        OpsGeoPoint location = doc.docFieldGeoPoint("location");
        double longitude = location.getLongitude();
        if (longitude < 0 || longitude > 180.0) {
            return 0;
        }
        return 1.0;
    }
}

docFieldTimestamp

OpsTimestamp docFieldTimestamp(CString fieldName)

Gets the value of a TIMESTAMP-type attribute field as an OpsTimestamp object.

Parameters:

ParameterTypeDescription
fieldNameCStringName of the attribute field. Must be a constant.

Returns: An OpsTimestamp object.

Returns null if the field does not exist or the field type is invalid. Import com.aliyun.opensearch.cava.framework.OpsTimestamp before using this function.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;
import com.aliyun.opensearch.cava.framework.OpsTimestamp;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().requireAttribute("timestamp");
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        OpsTimestamp timestamp = doc.docFieldTimestamp("timestamp");
        return (double)timestamp.getValue();
    }
}

declareLongVariable

boolean declareLongVariable(CString variableName, boolean needSerialize)

Declares a LONG variable for use across multiple plugins or to include its value in search results.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable. Must be a constant.
needSerializebooleanWhether to include the variable value in returned documents. Must be a constant. Valid values: true, false.

Returns: true if declared successfully; false otherwise.

Call this function only in init. A plugin can declare a maximum of 30 variables. Exceeding this limit returns an error.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsRequest;
import com.aliyun.opensearch.cava.framework.OpsDoc;
import com.aliyun.opensearch.cava.framework.OpsGeoPoint;
import com.aliyun.opensearch.cava.framework.OpsTimestamp;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().declareLongVariable("v_int64", true);
    }

    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        doc.setLongVariable("v_int64", 100);

        long longValue = doc.getLongVariable("v_int64");
        doc.trace("long value1: ", longValue);
        return 0;
    }
}

declareDoubleVariable

boolean declareDoubleVariable(CString variableName, boolean needSerialize)

Declares a DOUBLE variable for use across multiple plugins or to include its value in search results.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable. Must be a constant.
needSerializebooleanWhether to include the variable value in returned documents. Must be a constant. Valid values: true, false.

Returns: true if declared successfully; false otherwise.

Call this function only in init. A plugin can declare a maximum of 30 variables. Exceeding this limit returns an error.

Example:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsRequest;
import com.aliyun.opensearch.cava.framework.OpsDoc;
import com.aliyun.opensearch.cava.framework.OpsGeoPoint;
import com.aliyun.opensearch.cava.framework.OpsTimestamp;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return params.getDoc().declareDoubleVariable("v_double", true);
    }

    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        doc.setDoubleVariable("v_double", 100);

        long doubleValue = doc.getDoubleVariable("v_double");
        doc.trace("double value1: ", doubleValue);
        return 0;
    }
}

setLongVariable

void setLongVariable(CString variableName, long value)

Sets the value of a declared LONG variable. Call this in the score function.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable.
valuelongValue to assign.
The variable must be declared in init via declareLongVariable before calling this function.

setDoubleVariable

void setDoubleVariable(CString variableName, long value)

Sets the value of a declared DOUBLE variable. Call this in the score function.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable.
valuelongValue to assign.
The variable must be declared in init via declareDoubleVariable before calling this function.

getLongVariable

long getLongVariable(CString variableName)

Gets the value of a declared LONG variable. Call this in the score function.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable.

Returns: The current value of the variable. Returns 0 if the variable is not declared or its value has not been set.

getDoubleVariable

double getDoubleVariable(CString variableName)

Gets the value of a declared DOUBLE variable. Call this in the score function.

Parameters:

ParameterTypeDescription
variableNameCStringName of the variable.

Returns: The current value of the variable. Returns 0 if the variable is not declared or its value has not been set.

Trace functions

Unlike sort expressions, Cava sort scripts do not emit trace output automatically. Call trace explicitly in your score function to inspect values during debugging.

Warning

Trace output is only available on the Search Test page. Regular search requests do not support trace. Each trace call consumes runtime memory — use trace only when debugging, and remove or minimize trace calls before deploying to production.

To display multiple variables, call trace once per variable. The parameters used by the OpsDoc trace functions are fixed and cannot be changed.

All trace overloads follow the same pattern:

  • Single-argument form — emits the value directly

  • Two-argument form — emits a prefix label followed by the value, making it easier to identify outputs when multiple trace calls are active

Supported types

TypeSingle-argumentTwo-argument
BYTEvoid trace(byte value)void trace(CString prefix, byte value)
SHORTvoid trace(short value)void trace(CString prefix, short value)
INTvoid trace(int value)void trace(CString prefix, int value)
LONGvoid trace(long value)void trace(CString prefix, long value)
FLOATvoid trace(float value)void trace(CString prefix, float value)
DOUBLEvoid trace(double value)void trace(CString prefix, double value)
CStringvoid trace(CString value)void trace(CString prefix, CString value)

Examples

Trace a BYTE value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        byte value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace a BYTE value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        byte value = 1;
        doc.trace("byte value: ", value);
        return 0.0;
    }
}

Trace a SHORT value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        short value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace a SHORT value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        short value = 1;
        doc.trace("short value: ", value);
        return 0.0;
    }
}

Trace an INT value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        int value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace an INT value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        int value = 1;
        doc.trace("int value: ", value);
        return 0.0;
    }
}

Trace a LONG value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        long value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace a LONG value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        long value = 1;
        doc.trace("long value: ", value);
        return 0.0;
    }
}

Trace a FLOAT value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace a FLOAT value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        float value = 1.0;
        doc.trace("float value: ", value);
        return 0.0;
    }
}

Trace a DOUBLE value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        double value = 1;
        doc.trace(value);
        return 0.0;
    }
}

Trace a DOUBLE value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        double value = 1.0;
        doc.trace("double value: ", value);
        return 0.0;
    }
}

Trace a CString value:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        CString value = "abc";
        doc.trace(value);
        return 0.0;
    }
}

Trace a CString value with a prefix label:

package users.scorer;
import com.aliyun.opensearch.cava.framework.OpsScoreParams;
import com.aliyun.opensearch.cava.framework.OpsScorerInitParams;
import com.aliyun.opensearch.cava.framework.OpsDoc;

class BasicSimilarityScorer {
    boolean init(OpsScorerInitParams params) {
        return true;
    }
    double score(OpsScoreParams params) {
        OpsDoc doc = params.getDoc();
        CString value = "abc";
        doc.trace("CString value: ", value);
        return 0.0;
    }
}