Sets the visualization style you want returned.
Namespace: NetricsServerInterface
Assembly: NetricsServerInterface (in NetricsServerInterface.dll)
Syntax
Remarks
The definition is as follows:
0: | no visualization (default) |
2: | return the match strength arrays in the NetricsSearchResults object. |
256: | Return the HTML visualization strings. |
Example
This sample code shows how to specify search options such as setVisStyle on a multi-query operation.
![]() | |
---|---|
// This is an example of using some search options with a multi-query where different query strings // can be used in a search across different fields within a table. This requires first configuring a // Simple query for each query string along with the fields to be searched and then either "And" or "Or" // them together. // // In this we will query the "names" table using a query string against the "last" field and a another // query string against the "first" field. Each of these queries are referred to as a querylet. We will // apply a higher weight to the "last" field querylet. 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); // Table is the ibi™ Patterns - Search table to be search/matched against query String table = "names"; // Going to use 2 NetricsQuery for the search configuration NetricsQuery[] nqs = new NetricsQuery[2]; // Create NetricsSearchOpts object and then set some options NetricsSearchOpts opts = new NetricsSearchOpts(); // Set the search to SYMMETRIC scoring mode opts.scoreType(NetricsSearchOpts.score_types.SCORE_SYMMETRIC); // Set cutoff to exact matches plus the next 3 highest similarity score opts.useExactPlusScoreCutoff(3); // Set Empty Score to .2, eg. if field contains no data then use .2 score rather than 0. opts.setEmptyScore(.2); // Set visualization to html to add HTML tags to output to see text withing the records // which contribute to the similarity score. We'll need to use the getHTML method on the // NetricsSearchResult for the visualization data opts.setVisStyle(256); // If you want bold tags with HTML then set boldThresh to 2 opts.boldThresh(2); // Create the NetricsSearchCfg pointing to the table to be searched/matched against NetricsSearchCfg tblCfg = new NetricsSearchCfg(table); // Query will contain the query string for the first querylet which is "last String query = "brown"; // 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" }; // Create a Simple query for the "last" names search nqs[0] = NetricsQuery.Simple(query, fieldNames, null); // Set up the second Simple query query = "dennis"; fieldNames[0] = "first"; nqs[1] = NetricsQuery.Simple(query, fieldNames, null); // QueryletWeights is an array that must be the same length as the number of querylets // and is the weight applied to each querylet in the search which impacts the similarity // scrore. In this case there will be two querylets that will be ANDed together to create // a single search configuration double[] queryletWeights = { 1.0, .5 }; // Now AND the two Simple querys together to create the final NetricsQuery for the search NetricsQuery nqAnded = NetricsQuery.And(queryletWeights, nqs); // Set the NetricsSearchCfg; tblCfg.setNetricsQuery(nqAnded); // 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(); xfields = new String[res[0].getFieldNames().Length]; // Get the HTML data for each field in result record for (int fieldIdx = 0; fieldIdx < xfieldNames.Length; fieldIdx++ ) { xfields[fieldIdx] = res[i].getHtml(fieldIdx); } // 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"); } } } |