IRISLIB database
All Classes Namespaces Functions Variables Pages
Utils Class Reference

This class offers a number of utility methods for working with iFind. More...

Inheritance diagram for Utils:
Collaboration diagram for Utils:

Static Public Member Functions

_.Library.String Highlight (_.Library.String pText, _.Library.String pSearchString, _.Library.String pSearchOption, _.Library.String pTags, _.Library.Integer pLimit, _.Library.String pLanguage, _.Library.Status pSC)
 
_.Library.String NormalizeSearchString (_.Library.String pSearchString, _.Library.Status pSC)
 
_.Library.Float Rank (_.Library.String pRankerClass, _.Library.String pClassName, _.Library.String pIndexName, _.Library.RawString pRecordId, _.Library.String pSearchString, _.Library.String pSearchOptions, _.Library.Status pSC)
 
_.Library.Status TestSearchString (_.Library.String pSearchString, _.Library.String pNormalizedString, _.Library.String pDidYouMean)
 

Detailed Description

This class offers a number of utility methods for working with iFind.

Member Function Documentation

◆ Highlight()

_.Library.String Highlight ( _.Library.String  pText,
_.Library.String  pSearchString,
_.Library.String  pSearchOption,
_.Library.String  pTags,
_.Library.Integer  pLimit,
_.Library.String  pLanguage,
_.Library.Status  pSC 
)
static

This SQL procedure returns a marked-up version of pText, in which all matches of the

supplied pSearchString are highlighted using pTags.

SELECT iFind.Highlight('Great cocktails by the pool, but the bees were a bit of a bummer.', 'cocktail* OR (hammock AND NOT bees)')

pTags is a comma-separated list of tags to use for highlighting. If only a single one is supplied, it will be used to highlight all matches of search terms. If a second one is supplied, it will be used for all terms in a NOT node of the search tree (such as 'bees' in the above example), while the first will be used for all other terms.

pLimit can be used to limit the text to a maximum number of hits rather than returning the entire, highlighted text. pSearchOption can be used as in other iFind search operations, for example to also mark fuzzy matches or stem matches.

◆ NormalizeSearchString()

_.Library.String NormalizeSearchString ( _.Library.String  pSearchString,
_.Library.Status  pSC 
)
static

Normalizes the supplied pSearchString into an unambiguous combination of atomic

search strings, combined with AND, OR and NOT operators and appropriately surrounded by parentheses for clarifying operator precedence.

SELECT iFind.NormalizeSearchString('abc or (def* and not xyz)')

See also <method>TestSearchString</method>

◆ Rank()

_.Library.Float Rank ( _.Library.String  pRankerClass,
_.Library.String  pClassName,
_.Library.String  pIndexName,
_.Library.RawString  pRecordId,
_.Library.String  pSearchString,
_.Library.String  pSearchOptions,
_.Library.Status  pSC 
)
static

This SQL function returns a score for how well record pRecordId matches the supplied search

string pSearchString, according to the ranker implementation pRankerClass. This method can be invoked through SQL directly to override the default ranker class used by the Rank procedure that's generated automatically on the iFind-indexed class.

SELECT ID, Title, FullText, iFind.Rank('iFind.Rank.TFIDF', 'SomePackage.TheTable', 'MyIndex', ID, 'cocktail* OR (hammock AND NOT bees)') As Rank FROM SomePackage.TheTable WHERE ID FIND search_index(MyIndex, 'cocktail* OR (hammock AND NOT bees)') ORDER BY 4 DESC

See also <class>iFind.Rank.Abstract</class>.

◆ TestSearchString()

_.Library.Status TestSearchString ( _.Library.String  pSearchString,
_.Library.String  pNormalizedString,
_.Library.String  pDidYouMean 
)
static

Validates whether the supplied pSearchString is correct according to iFind search

syntax rules, returning a <class>Status</class> object capturing the correctness ($$$OK if the supplied string is valid, an error code if it is not).

SELECT iFind.TestSearchString('abc or (def* and not xyz)')

This method will also return a cleaned and unambiguous version of the search string through the pNormalized output argument. See also <method>NormalizeSearchString</method>.