ibi Patterns .NET API
Loading...
Searching...
No Matches
NetricsServerInterface.NetricsBaseRecord Class Reference

The base class for all types of records used in the ibi™ Patterns - Search interface. More...

Public Member Functions

String getKey ()
 Get the key of a record.
 
String getParentKey ()
 Retrieve the parent key of a record.
 
int numBytes ()
 Return the number of bytes of data in this record.
 
String[] getFields ()
 Can be used to get the content of a record.
 
String[] getAttrNames ()
 Returns the names of name/value attributes of the record.
 
String[] getAttrValues ()
 Returns the values of name/value attributes of the record.
 
String getAttribute (String attr_name)
 Gets the specified attribute value of the record.
 
override String ToString ()
 

Detailed Description

The base class for all types of records used in the ibi™ Patterns - Search interface.

Records can be single table records (see NetricsRecord) or compound records (see NetricsCompoundRecord) consisting of a parent record and one or more child records. If a single table record is required the NetricsRecord class should be used. If compound records are required the NetricsCompoundRecord class should be used. If a method handles either type of record this class should be used. In general only generic utilities or applications that simply pass data through should use this base class.

This class contains the implementation for the common properties of all record types. All records have field structure. The field structure in the record must match the field structure of the table it is loaded into.

Member Function Documentation

◆ getAttribute()

String NetricsServerInterface.NetricsBaseRecord.getAttribute ( String  attr_name)
inline

Gets the specified attribute value of the record.

This assumes the last field of the record contains the encoded attribute values and attempts to decode them. If the decode fails it returns null, otherwise it attempts to retrieve the named attributes, returning the value if found, null if not.

Parameters
attr_nameName of the attribute to retrieve.

◆ getAttrNames()

String[] NetricsServerInterface.NetricsBaseRecord.getAttrNames ( )
inline

Returns the names of name/value attributes of the record.

Returns null if the record has no name/value attributes.

◆ getAttrValues()

String[] NetricsServerInterface.NetricsBaseRecord.getAttrValues ( )
inline

Returns the values of name/value attributes of the record.

Returns null if the record has no name/value attributes.

◆ getFields()

String[] NetricsServerInterface.NetricsBaseRecord.getFields ( )
inline

Can be used to get the content of a record.

This sample shows how to perform a search of an ibi™ Patterns - Search table using a Simple query and retrieving data using the getFields method.

// In this example a Simple search will be configured. The sample demonstrates searching
// the names table for the query string "brown dennis". The fields to matched against this
// string are "last" and "first". The weight for "last" is 1.0 and for "first" is .5. In this
// case the "last" name will have a higher importance in the score so that records with a "last"
// match will have a higher similarity score than those of "first" and will appear higher in the
// result set in the response.
class MyClass
{
public static void Main()
{
try
{
String host = "localhost";
int port = 5051;
// Query will contain the query string or tokens to be matched against
String query = "brown dennis";
// Table is the <i>ibi Patterns - Search</i> table to be search/matched against query
String table = "names";
// FieldNames contain the fields within the table to be searhed/matched against.
// If fieldNames is set to null then all fields will be searched/matched against
String[] fieldNames = {"last" , "first"};
// FieldWeights is an array that must be the same length as fields and contain the
// weights (0.0 - 1.0) of each field that contribute to the overall score of the result
double[] fieldWeights = { 1.0, .5 };
// Create NetricsSearchOpts object using the defaults
// Create the NetricsSearchCfg pointing to the table to be searched/matched against
NetricsSearchCfg tblCfg = new NetricsSearchCfg(table);
// Add a Simple query to the NetricsSearchCfg using the query, fieldNames and fieldWeights
tblCfg.setNetricsQuery(NetricsQuery.Simple(query, fieldNames, fieldWeights));
// Perform the search/match using the NetricsSearchCfg and NetricsSearchOpts
NetricsSearchResponse resp = si.search(tblCfg, opts);
String s = "";
// Get the results of the search/match
// 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");
}
}
}
String[] getFields()
Can be used to get the content of a record.
Definition: NetricsBaseRecord.cs:349
A NetricsException is thrown whenever an error occurs.
Definition: NetricsException.cs:32
String getErrorDescription()
Get the description of the error.
Definition: NetricsException.cs:110
String[] getFieldNames()
Returns an array of Strings which are the names of the fields for the source table of the record.
Definition: NetricsMappedRecord.cs:120
NetricsQuery objects are used to implement the complex query structures introduced with release 4....
Definition: NetricsQuery.cs:66
static NetricsQuery Simple(String qstr, String[] fldnames, double[] fldweights)
Create a Simple Query Expression Node.
Definition: NetricsQuery.cs:397
This class is used with the search methods of the NetricsServerInterface class to configure a query.
Definition: NetricsSearchCfg.cs:23
void setNetricsQuery(NetricsQuery nq)
Set the NetricsQuery to be performed.
Definition: NetricsSearchCfg.cs:170
This class is used to configure search options which apply for the overall search (for all tables bei...
Definition: NetricsSearchOpts.cs:17
This class represents the ibi™ Patterns - Search Server's response to a search command.
Definition: NetricsSearchResponse.cs:23
NetricsSearchResult[] getSearchResults()
Get the records returned by the search.
Definition: NetricsSearchResponse.cs:194
This class extends NetricsMappedRecord adding information relevant to a search result (match score,...
Definition: NetricsSearchResult.cs:24
double getMatchScore()
Get the overall match score for this record.
Definition: NetricsSearchResult.cs:236
Base class for all interactions with the ibi™ Patterns - Search Server.
Definition: NetricsServerInterface.cs:62
NetricsSearchResponse search(NetricsSearchCfg cfg, NetricsSearchOpts opts)
Version of search to search a single table.
Definition: NetricsServerInterface.cs:1321
ibi™ Patterns - Search .NET Interface Overview.
Definition: BaseObjectStats.cs:14

◆ getKey()

String NetricsServerInterface.NetricsBaseRecord.getKey ( )
inline

Get the key of a record.

This does not contain any parent record key if this is a child table.

◆ getParentKey()

String NetricsServerInterface.NetricsBaseRecord.getParentKey ( )
inline

Retrieve the parent key of a record.

If this is not a child record this returns null.

◆ ToString()

override String NetricsServerInterface.NetricsBaseRecord.ToString ( )
inline

Return a human readable string representation of the record. This returns a string version of the record. The format is a single CSV format record where the first field is the record key, the second field is the parent key, and the following fields are are the data fields of the record, including the string encoded attributes field if the record contains attributes. All values are double quoted unless the value was null, in which case the value is the empty string with no double quotes.

Returns
this string representation as described above.