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
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
| Signature | Field type | Returns |
|---|---|---|
boolean requireAttribute(CString fieldName) | — | true if declared; false otherwise |
long docFieldLong(CString fieldName) | INT | long |
float docFieldFloat(CString fieldName) | FLOAT | float |
double docFieldDouble(CString fieldName) | DOUBLE | double |
CString docFieldLiteral(CString fieldName) | LITERAL | CString |
long[] docFieldLongArray(CString fieldName) | INT_ARRAY | long[], or null on failure |
float[] docFieldFloatArray(CString fieldName) | FLOAT_ARRAY | float[], or null on failure |
double[] docFieldDoubleArray(CString fieldName) | DOUBLE_ARRAY | double[], or null on failure |
CString[] docFieldLiteralArray(CString fieldName) | LITERAL_ARRAY | CString[], or null on failure |
OpsGeoPoint docFieldGeoPoint(CString fieldName) | GEO_POINT | OpsGeoPoint, or null on failure |
OpsTimestamp docFieldTimestamp(CString fieldName) | TIMESTAMP | OpsTimestamp, or null on failure |
Variable management
| Signature | Phase | Description |
|---|---|---|
boolean declareLongVariable(CString variableName, boolean needSerialize) | init only | Declares a LONG variable |
boolean declareDoubleVariable(CString variableName, boolean needSerialize) | init only | Declares a DOUBLE variable |
void setLongVariable(CString variableName, long value) | score only | Sets a LONG variable value |
void setDoubleVariable(CString variableName, long value) | score only | Sets a DOUBLE variable value |
long getLongVariable(CString variableName) | score only | Gets a LONG variable value |
double getDoubleVariable(CString variableName) | score only | Gets 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name 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.
requireAttributecan 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: The field value as long[].
Returnsnullif the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check fornullbefore 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: The field value as float[].
Returnsnullif the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check fornullbefore 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: The field value as double[].
Returnsnullif the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check fornullbefore 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: The field value as CString[].
Returnsnullif the field does not exist, the type cannot be converted, or the field is not an ARRAY type. Always check fornullbefore 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: An OpsGeoPoint object.
Returnsnullif the field does not exist or the field type is invalid. Importcom.aliyun.opensearch.cava.framework.OpsGeoPointbefore 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:
| Parameter | Type | Description |
|---|---|---|
fieldName | CString | Name of the attribute field. Must be a constant. |
Returns: An OpsTimestamp object.
Returnsnullif the field does not exist or the field type is invalid. Importcom.aliyun.opensearch.cava.framework.OpsTimestampbefore 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:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name of the variable. Must be a constant. |
needSerialize | boolean | Whether 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:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name of the variable. Must be a constant. |
needSerialize | boolean | Whether 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:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name of the variable. |
value | long | Value to assign. |
The variable must be declared ininitviadeclareLongVariablebefore 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:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name of the variable. |
value | long | Value to assign. |
The variable must be declared ininitviadeclareDoubleVariablebefore calling this function.
getLongVariable
long getLongVariable(CString variableName)Gets the value of a declared LONG variable. Call this in the score function.
Parameters:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name 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:
| Parameter | Type | Description |
|---|---|---|
variableName | CString | Name 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.
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
prefixlabel followed by the value, making it easier to identify outputs when multiple trace calls are active
Supported types
| Type | Single-argument | Two-argument |
|---|---|---|
| BYTE | void trace(byte value) | void trace(CString prefix, byte value) |
| SHORT | void trace(short value) | void trace(CString prefix, short value) |
| INT | void trace(int value) | void trace(CString prefix, int value) |
| LONG | void trace(long value) | void trace(CString prefix, long value) |
| FLOAT | void trace(float value) | void trace(CString prefix, float value) |
| DOUBLE | void trace(double value) | void trace(CString prefix, double value) |
| CString | void 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;
}
}