public class NetricsQuery
extends java.lang.Object
implements java.io.Serializable
NetricsSearchCfg tblCfg = new NetricsSearchCfg("test"); tblCfg.setNetricsQuery(NetricsQuery.Simple("Michael Phelps",null,null)); NetricsSearchResponse resp = si.search(tblCfg, null);The above code will search the table "test" (all fields) for the string "Michael Phelps." It's just that easy. A much more complicated search might look like the following:
String []fnames = {"name1"}; NetricsQuery nq1 = NetricsQuery.Simple("rec1f1",fnames,null); String []queries = {"rec1f2","rec1f1"}; String []fnames2 = {"name1","name2"}; NetricsQuery nq2 = NetricsQuery.Cognate(queries,fnames2,null,.8); String []fnames3 = {"date"}; NetricsQuery nq3 = NetricsQuery.Custom("10/12/2001",fnames3,null,NetricsQuery.CS_DATE); NetricsQuery nq4 = NetricsQuery.Predicate("DATE \"2001/01/01\" <= $\"date\" and $\"date\" <= DATE \"2001/12/31\"") ; NetricsQuery []nqs = {nq1,nq2,nq3,nq4}; NetricsQuery nq = NetricsQuery.And(null,nqs);The above query combines 4 different querylets using an AND (which performs a simple average of the individual scores). The first querylet is a simple string comparison, the second is a cognate string comparison, the third is a date comparison, and the fourth is a predicate comparison. Look below to find out more about each kind of query.
Modifier and Type | Field and Description |
---|---|
static int |
CS_DATE
Custom Date comparison scorer
|
static int |
CS_NONE
Not a custom scorer
|
Constructor and Description |
---|
NetricsQuery() |
Modifier and Type | Method and Description |
---|---|
static NetricsQuery |
And(double[] weights,
NetricsQuery[] nqs)
Create an AND Query Expression Node
This is used to combine multiple NetricsQuery scores into a single score. |
static NetricsQuery |
And(double[] weights,
NetricsQuery[] nqs,
double[] ignore_scores)
Create an AND Query Expression Node with ignore scores.
|
static NetricsQuery |
And(double[] weights,
NetricsQuery[] nqs,
double[] ignore_scores,
double[] reject_scores)
Create an AND Query Expression Node with ignore scores and reject scores.
|
static NetricsQuery |
Attributes(java.lang.String[] attr_values,
java.lang.String[] attr_names,
double[] attr_weights)
Create a Variable Attributes Query node.
|
static NetricsQuery |
Cognate(java.lang.String[] qstrs,
java.lang.String[] fldnames,
double[] fldweights,
double noncogwgt)
Create a Cognate Query Expression Node.
|
static NetricsQuery |
Custom(java.lang.String qstr,
java.lang.String[] fldnames,
double[] fldweights,
int customtype)
Create a Custom Query node.
|
void |
NetricsQuery()
Create an empty Query Node.
|
static NetricsQuery |
Not(NetricsQuery nq)
Create a NOT Query Expression Node.
|
static NetricsQuery |
Or(double[] weights,
NetricsQuery[] nqs)
Create an OR Query Expression Node.
|
static NetricsQuery |
Predicate(NetricsPredicate pred)
Create a Predicate Query Expression Node.
|
static NetricsQuery |
Predicate(java.lang.String expr)
Create a Predicate Query Expression Node from a string predicate.
|
static NetricsQuery |
Rlink(java.lang.String modelname,
NetricsQuery[] nqs)
Create an RLINK Query Expression Node.
|
void |
scoreType(int scoreType)
This specifies the type of score to be used for ordering records.
|
void |
setEmptyScore(double score)
Sets the score a comparison gets when empty data is encountered.
|
void |
setInvalidScore(double score)
Sets the score a comparison gets when invalid data is encountered.
|
void |
setXparm(int id,
double value)
Use this method only on the advice of your Netrics representative.
|
void |
setXparm(int id,
int value)
Use this method only on the advice of your Netrics representative.
|
static NetricsQuery |
Simple(java.lang.String qstr,
java.lang.String[] fldnames,
double[] fldweights)
Create a Simple Query Expression Node.
|
void |
useEphemeralThesaurus(com.netrics.likeit.NetricsBaseThesaurus thes_def,
double theswgt)
Assign an ephemeral thesaurus to be used by this NetricsQuery.
|
void |
useThesaurus(java.lang.String thesname,
double theswgt)
Assign a thesaurus to be used by the NetricsQuery object.
|
static NetricsQuery |
Wgtbyfield(java.lang.String fieldName,
NetricsQuery nq)
Create a weighted field query expression node.
|
public static int CS_NONE
public static int CS_DATE
public void NetricsQuery()
public static NetricsQuery Custom(java.lang.String qstr, java.lang.String[] fldnames, double[] fldweights, int customtype)
qstr
- the query stringfldnames
- list of fields to queryfldweights
- list of weights for fieldcustomtype
- type of the custom querypublic static NetricsQuery Simple(java.lang.String qstr, java.lang.String[] fldnames, double[] fldweights)
qstr
- the query stringfldnames
- list of fields to queryfldweights
- list of weights for fieldpublic static NetricsQuery And(double[] weights, NetricsQuery[] nqs)
weights
- list of floats that are the weights
for the sub expressions of this querynqs
- array of NetricsQuery objects that are the sub
expressions for this ANDpublic static NetricsQuery And(double[] weights, NetricsQuery[] nqs, double[] ignore_scores)
weights
- list of floats that are the weights
for the sub expressions of this querynqs
- array of NetricsQuery objects that are the sub
expressions for this ANDignore_scores
- array of floats that are the ignore-scores for the sub expressions for this ANDsetEmptyScore(double)
,
setInvalidScore(double)
public static NetricsQuery And(double[] weights, NetricsQuery[] nqs, double[] ignore_scores, double[] reject_scores)
weights
- list of floats that are the weights
for the sub expressions of this querynqs
- array of NetricsQuery objects that are the sub
expressions for this ANDignore_scores
- array of floats that are the ignore-scores for the sub expressions for this ANDreject_scores
- array of floats that are the reject-scores for the sub expressions for this ANDsetEmptyScore(double)
,
setInvalidScore(double)
public static NetricsQuery Or(double[] weights, NetricsQuery[] nqs)
weights
- list of floats that are the weights
for the sub expressions of this querynqs
- list of NetricsQuery objects that are the sub
expressions for this OR.public static NetricsQuery Not(NetricsQuery nq)
nq
- NetricsQuery object that is the sub expression for this NOT.public static NetricsQuery Wgtbyfield(java.lang.String fieldName, NetricsQuery nq)
public static NetricsQuery Attributes(java.lang.String[] attr_values, java.lang.String[] attr_names, double[] attr_weights)
attr_values
- the list of attribute values to be matched.attr_names
- the list of names of the attribute to be matched.
This must correspond to the attr_values.attr_weights
- the list of weighting factors for each
attribute. This may be null, in which case all
attributes get equal weights. If given this must match the
attr_values and attr_names arrays.public static NetricsQuery Rlink(java.lang.String modelname, NetricsQuery[] nqs)
modelname
- the name of the decision engine model to usenqs
- list of NetricsQuery objects that are the sub
expressions for this RLINK expression.public static NetricsQuery Cognate(java.lang.String[] qstrs, java.lang.String[] fldnames, double[] fldweights, double noncogwgt)
qstrs
- the list of query stringsfldnames
- list of fields to queryfldweights
- list of weights for fieldnoncogwgt
- penalty applied to diagonal (non-cognate) field matchespublic void useThesaurus(java.lang.String thesname, double theswgt) throws NetricsException
thesname
- the name of the thesaurustheswgt
- the weight to give thesaurus matchesNetricsException
public void useEphemeralThesaurus(com.netrics.likeit.NetricsBaseThesaurus thes_def, double theswgt) throws NetricsException
thes_def
- A thesaurus object (an object of any class extending
NetricsBaseThesaurus).theswgt
- the weight to give thesaurus matchesNetricsException
NetricsThesaurus
,
NetricsWeightedDictionary
,
NetricsCombinedThesaurus
public void setXparm(int id, int value) throws NetricsException
NetricsException
public void setXparm(int id, double value) throws NetricsException
NetricsException
public static NetricsQuery Predicate(NetricsPredicate pred)
pred
- the NetricsPredicate object to evaluatepublic static NetricsQuery Predicate(java.lang.String expr)
expr
- the string predicate expressionpublic void setInvalidScore(double score)
score
- the score to be assigned.public void setEmptyScore(double score)
score
- the score to be assigned.public void scoreType(int scoreType)