Sets the score a comparison gets when an error occurs.


Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)

Syntax

Visual Basic (Declaration)
Public Sub setInvalidScore( _ 
   ByVal score As Double _ 
)
C#
public void setInvalidScore(
   double score
)
C++
public:
 void setInvalidScore(
   double score
) sealed 
J#
public void setInvalidScore(
   double score
)
JScript
public  function setInvalidScore(
   score : double
)

Remarks

A comparison will receive this score when an error occurs. In some situations it is more appropriate to set this score to 0.0 or -1.0, and the user is therefore allowed to configure this setting.

Example

This sample demonstrates a Custom date query and setting the score to .5 if the date field contains invalid data.

 Copy Code
            using System;
            using NetricsServerInterface;
            class MyClass
            {
                private static NetricsServerInterface.NetricsServerInterface si = null;
                public static void Main()
                {
                    try
                    {
                        String host = "localhost";
                        int port = 5051;
                        si = new NetricsServerInterface.NetricsServerInterface(host, port);
                        // Quuery will contain the query string or tokens to be matched against
                        String query = "1/30/1996";
                        // Table is the TIBCO Patterns Engine table to be search/matched against query
                        String table = "employee";
                        // FieldNames contain the date field within the table to be searhed/matched against.
                        String[] fieldNames = { "HIRE_DATE" };
                        // Set field weights to null
                        double[] fieldWeights = null;
                        // Create NetricsSearchOpts object using the defaults
                        NetricsSearchOpts opts = new NetricsSearchOpts();
                        // Create the NetricsSearchCfg pointing to the table to be searched/matched against
                        NetricsSearchCfg tblCfg = new NetricsSearchCfg(table);
                        // Add a Custom query to the NetricsSearchCfg using the query, fieldNames, fieldWeights and CS_DATE
                        NetricsQuery nq = NetricsQuery.Custom(query, fieldNames, fieldWeights, NetricsQuery.CS_DATE);
                        // If the "HIRE_DATE" field contains invalid data set the score to 0.5 rather than the default of 0.0
                        nq.setInvalidScore(.5);
                        tblCfg.setNetricsQuery(nq);
                        // Perform the search/match using the NetricsSearchCfg and NetricsSearchOpts
                        NetricsSearchResponse resp = si.search(tblCfg, opts);
                        String s = "";
                        // Get the results of the search/match
                        NetricsSearchResult[] res = resp.getSearchResults();
                        // Create viables for result processing
                        String[] xfieldNames;
                        String[] xfields;
                        // Iterate through the result records
                        for (int i = 0; i < res.Length; i++)
                        {
                            // Get the fieldNames in the result record
                            xfieldNames = res[i].getFieldNames();
                            // Get the data for each fieldName in result record
                            xfields = res[i].getFields();
                            // Get the score for this result record
                            double score = res[i].getMatchScore();
                            // Build the printline for the result record
                            s = s + "Rank=" + i + ", Score=" + score.ToString();
                            for (int x = 0; x < xfields.Length; x++)
                            {
                                s = s + ", " + xfieldNames[x] + "=" + xfields[x];
                            }
                            s = s + "\n";
                        }
                        Console.WriteLine(s);
                    }
                    catch (NetricsException e)
                    {
                        Console.Write(e.getErrorDescription() + "\n");
                    }
                }
            }
            

See Also