public class NetricsSearchCfg
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
NetricsSearchCfg(java.lang.String tblname) |
Modifier and Type | Method and Description |
---|---|
void |
addQuery(java.lang.String query,
java.lang.String[] names)
Deprecated.
As of release 4.1.1. Use
setNetricsQuery(NetricsQuery) |
void |
addQuery(java.lang.String query,
java.lang.String[] names,
double[] fieldWeights,
double queryletWeight,
int alignField,
java.lang.String thesaurusName)
Deprecated.
As of release 4.1.1. Use
setNetricsQuery(NetricsQuery) |
static NetricsPredicate |
CreateBoolOperand(boolean b)
Create a predicate constant value of type boolean.
|
static NetricsPredicate |
CreateDoubleOperand(double d)
Create a predicate constant of type double.
|
static NetricsPredicate |
CreateFieldNameOperand(java.lang.String fn)
Create a predicate reference to a field using a field name.
|
static NetricsPredicate |
CreateIntOperand(int i)
Create a predicate constant value of type int.
|
static NetricsPredicate |
CreatePredicate(NetricsPredicate predl,
int op,
NetricsPredicate predr)
Create a predicate by combining two predicates that were previously created.
|
static NetricsPredicate |
CreateStringOperand(java.lang.String s)
Create a predicate constant of type String.
|
static NetricsPredicate |
CreateUnaryPredicate(NetricsPredicate pred,
int op)
Create a predicate by combining a single predicate and an operation to be performed on the predicate.
|
void |
makeDependentQuerylets(int[] multiqueryletIds)
Deprecated.
As of release 4.1.1. Use
setNetricsQuery(NetricsQuery) |
void |
setLockKey(NetricsLock lock)
Set the lock key for this search.
|
void |
setNetricsQuery(NetricsQuery nq)
Set the NetricsQuery object for this database.
|
void |
SetSearchPredicate(NetricsPredicate pred)
Set the search predicate for a given search.
|
void |
SetSearchPredicate(java.lang.String expr)
Set the search predicate from a string.
|
public void setNetricsQuery(NetricsQuery nq)
NetricsQuery
public void setLockKey(NetricsLock lock)
public void addQuery(java.lang.String query, java.lang.String[] names)
setNetricsQuery(NetricsQuery)
query
- The query that will be used to search the given field names.names
- The field names against which the query will be searched (null will search all fields in the table).public void addQuery(java.lang.String query, java.lang.String[] names, double[] fieldWeights, double queryletWeight, int alignField, java.lang.String thesaurusName)
setNetricsQuery(NetricsQuery)
query
- The query that will be used to search the given field names.names
- The field names against which the query will be searched.fieldWeights
- An array of doubles which weigh the importance of fields. Use a higher number to weigh a given field as more important. The doubles are one per field for the fields specified for this query (the lengths of the 2nd and 3rd parameters to this method should be the same). The valid range for the doubles is from 0.0 to 1.0 (In the Netrics Java Interface, UNLIKE OTHER NETRICS INTERFACES, field weights are normalized for you).queryletWeight
- Specifies the fraction of the entire record score that should come from this querylet. (A value of -1.0 will set each querylet to an equal weight.) If you set a queryletWeight for a query, you must set a queryletWeight for every query for the table.alignField
- The field number which this querylet will most likely be found in. This can be used as a hint to the search algorithm (field numbers start at 0).thesaurusName
- The name of a thesaurus to be used just for this querylet. (A null string will not use a thesaurus for the querylet.)public void makeDependentQuerylets(int[] multiqueryletIds) throws NetricsException
setNetricsQuery(NetricsQuery)
multiqueryletIds
- Any two querylets that are dependent are part of the same "multiquerylet." The multiqueryletIds parameter should be the same length as the number of querylets added to the NetricsSearchCfg. Each position in the array is the ID of the multiquerylet that querylet belongs to. In this way, if any two positions in the array have the same multiquerylet id, they will be added to the same multiquerylet and will thus be dependent querylets. It is an error to use multiquerylet ids less than 0 or greater than the number of querylets added to the NetricsSearchCfg object. For example, with querylets "First Name", "Last Name", and "Address", the array {0,0,1} would make the first two querylets dependent and the last querylet independent of the other two.NetricsException
public static NetricsPredicate CreateIntOperand(int i)
NetricsPredicate
public static NetricsPredicate CreateBoolOperand(boolean b)
NetricsPredicate
public static NetricsPredicate CreateStringOperand(java.lang.String s)
NetricsPredicate
public static NetricsPredicate CreateDoubleOperand(double d)
NetricsPredicate
public static NetricsPredicate CreateFieldNameOperand(java.lang.String fn)
NetricsPredicate
public static NetricsPredicate CreatePredicate(NetricsPredicate predl, int op, NetricsPredicate predr)
op
parameter is applied between the two predicates. The possible op
codes are listed in the table below.
Operator Id | Description |
NetricsPredicate.EQUALS | The equality operator (==) - valid for string comparisons as well |
NetricsPredicate.INSEN_EQUALS | The equality operator (==) - valid for case insensitive string comparisons as well |
NetricsPredicate.LESSTHEN | The less than operator (<) |
NetricsPredicate.INSEN_LESSTHEN | The case insensitive less than operator (<) |
NetricsPredicate.LESSTHENOREQ | The less that or equal to operator (<=) |
NetricsPredicate.INSEN_LESSTHENOREQ | The case insensitive less that or equal to operator (<=) |
NetricsPredicate.GREATERTHAN | The greater than operator (>) |
NetricsPredicate.INSEN_GREATERTHAN | The case insensitive greater than operator (>) |
NetricsPredicate.GREATERTHANOREQ | The greater than or equal to operator (>=) |
NetricsPredicate.INSEN_GREATERTHANOREQ | The case insensitive greater than or equal to operator (>=) |
NetricsPredicate.PLUS | The addition operator (+) |
NetricsPredicate.MINUS | The subtraction operator (-) |
NetricsPredicate.TIMES | The multiplication operator (*) |
NetricsPredicate.DIVIDEDBY | The division operator (/) |
NetricsPredicate.TOTHE | The exponent operator (^) |
NetricsPredicate.AND | The AND operator (&&) |
NetricsPredicate.OR | The OR operator (||) |
NetricsPredicate.ISIN | The substring operator - detects substring matches of the left operand in the right operand |
NetricsPredicate.INSEN_ISIN | The substring operator - detects substring matches of the left operand in the right operand ignoring letter case |
NetricsPredicate.TOKENIZE | The tokenize operator |
NetricsPredicate.SUPERSET | The superset operator |
NetricsPredicate.SUBSET | The subset operator |
NetricsPredicate
public static NetricsPredicate CreateUnaryPredicate(NetricsPredicate pred, int op)
op
codes are listed in the table below.
Operator Id | Description |
NetricsPredicate.MINUS | Negate - equivalent to multiplying by -1 |
NetricsPredicate.NOT | Not - logical negation (!) |
NetricsPredicate.TOINT | To int type (cast) |
NetricsPredicate.TODBL | To float type (cast) |
NetricsPredicate.TODATE | To date type |
NetricsPredicate.TODATEEU | To EU date type (European data format) |
NetricsPredicate.TOKENIZE | Tokenize |
NetricsPredicate.TOBLK | To block type |
NetricsPredicate.TODATET | To date type, with time (default format yyyy/mm/dd HH:MM:SS) |
NetricsPredicate.TODATEEUT | To EU date type, with time |
NetricsPredicate.ABS | Absolute Value |
NetricsPredicate
public void SetSearchPredicate(NetricsPredicate pred)
NetricsPredicate
public void SetSearchPredicate(java.lang.String expr)
?TRUE?, ?FALSE? | Boolean constant values are true and false enclosed in question marks. Letter case insensitive |
123,0777,0x8FFF | Integer constant values. They follow the standard "C" and Java conventions for decimal, Octal and Hex integers. |
123.45, 0.17e-10 | Floating point values. They follow the standard "C" and Java conventions for fixed and scientific notation values. |
"string" | string constants are enclosed in double quotes. The basic XML/HMTL encoding scheme is used to represent the double quote character (") itself and other special characters. The numeric conventions: &#ddd;, &#xhh; are recognized and the entity names: quot, amp, lt, gt and apos are recognized. No other entity names are recognized. Note that you must NOT insert an encoded NULL character into the string as this is a NULL terminated string value. |
:"byte block" | A byte block is specified by preceding a quoted string value with a colon (:) character. The length of the block is computed automatically. All non-valid string characters must be encoded using the XML/HTML like encodings as defined for strings. |
#2 | Table fields specified by numeric position. An integer value preceded with the pound (#) character is used to represent the table field at the indicated column position. Like array indexes in Java and "C" these field numbers are zero based. |
$"first name" | Table fields specified by field name. A quoted string value (see string description above) preceded by the dollar ($) sign. The string value is the field name. |
[ :] | Block arrays. A comma separated list of blocks enclosed in square brackets ([]). To specify a Block array with zero entries use an open bracket followed by colon close bracket (:]) no space between the colon and close bracket. |
INT $"age" > 21
((INT $"age" + INT $"years experience") / 2) - 1 >= 21
2 + 3 + 12
(2 + 3) + 12
12 + 2 * 3
12 + (2 * 3)
a - b + c
is the same as a - (b + c)
not (a - b) + c
operators | description |
** | raise to power |
* | multiple |
/ | divide |
+ | addition for numbers, concatenation for strings |
- | subtraction |
=, ==, ~=, >, ~> >=, ~>=, <, ~<, <=, ~<=, SUBSET, SUPERSET, IN | Comparison operators, "=" and "==" are synonyms. Comparison operators prefixed with ~ perform letter case insensitive comparisons. |
AND | Logical and joining operator, similar to the Java && operator |
OR | Logical or joining operator, similar to the Java || operator |
operator | description |
+ | arithmetic positive, this does nothing |
- | arithmetic negation |
NOT | logical inverse |
UPPER | convert character string/byte block to upper case |
LOWER | convert character string/byte block to lower case |
INT | convert value to integer |
DBL DOUBLE FLOAT | convert value to floating point. These are all synonyms for the same operation. |
DATE | convert value to a date. |
DATEEU EUDATE | convert value to a date. String and byte block format dates are assumed to be in European format. These are synonyms for the same operation |
BLOCK | convert value to a byte block. |
SPLIT TOKENIZE | split a string or block into a block array with each element of the array being a word from the string. |
ABS | return the Absolute Value of an integer or double value. |
NetricsSearchCfg tblcfg = new NetricsSearchCfg("tbl");
tblcfg.SetSearchPredicate("$\"Company\" == \"Pepsi\" or $\"Company\" == \"Coke\"");
NetricsPredicate