Create a Custom Query node.
Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function Custom( _ ByVal qstr As String, _ ByVal fldnames As String(), _ ByVal fldweights As Double(), _ ByVal customtype As Integer _ ) As NetricsQuery |
C# |
---|
public static NetricsQuery Custom( string qstr, string[] fldnames, double[] fldweights, int customtype ) |
C++ |
---|
public: static NetricsQuery Custom( String qstr, array<String>^ fldnames, array<double>^ fldweights, int customtype ) |
J# |
---|
public static NetricsQuery Custom( string qstr, string[] fldnames, double[] fldweights, int customtype ) |
JScript |
---|
public static
function Custom( qstr : String, fldnames : String[], fldweights : double[], customtype : int ) : NetricsQuery |
Parameters
- qstr
- the query string
- fldnames
- list of fields to query
- fldweights
- list of weights for field
- customtype
- type of the custom query
Remarks
Currently there is only one custom query type and that is NetricsQuery.CS_DATE. To perform a date search, pass the query date in "qstr," the single date field in the "fldnames" vector, set fldweights to null, and set the customtype to NetricsQuery.CS_DATE. A date comparison will look for inversions between month and date, misplaced century information, and other qualities that a normal string comparison would not take into account.
Example
This sample shows how to perform a search using a date field and the Customer Query.
![]() | |
---|---|
// This is an example of using the Custom query to perform a search. A Custom query utilizes a field // of type date or datetime to do a date comparison. In this case we are looking for any employee // with a "HIRE_DATE" of "1/30/1996". 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 tblCfg.setNetricsQuery(NetricsQuery.Custom(query, fieldNames, fieldWeights, NetricsQuery.CS_DATE)); // 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"); } } } |