Create a Simple Query Expression Node
Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function Simple( _ ByVal qstr As String, _ ByVal fldnames As String(), _ ByVal fldweights As Double() _ ) As NetricsQuery |
C# |
---|
public static NetricsQuery Simple( string qstr, string[] fldnames, double[] fldweights ) |
C++ |
---|
public: static NetricsQuery Simple( String qstr, array<String>^ fldnames, array<double>^ fldweights ) |
J# |
---|
public static NetricsQuery Simple( string qstr, string[] fldnames, double[] fldweights ) |
JScript |
---|
public static
function Simple( qstr : String, fldnames : String[], fldweights : double[] ) : NetricsQuery |
Parameters
- qstr
- the query string
- fldnames
- list of fields to query
- fldweights
- list of weights for field
Remarks
This is the basic Netrics query and is used to compare an arbitrary query string against a field set in a table.
Example
This sample shows how to perform a search of a TIBCO Patterns Engine table using a Simple query.
![]() | |
---|---|
// 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. 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); // Query will contain the query string or tokens to be matched against String query = "brown dennis"; // Table is the TIBCO Patterns Engine 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 NetricsSearchOpts opts = new NetricsSearchOpts(); // 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 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"); } } } |