IRISLIB database
Basic Class Reference
Inheritance diagram for Basic:
Collaboration diagram for Basic:

Static Public Member Functions

_.Library.String Highlight (_.Library.RawString pRecordID, _.Library.String pSearchString, _.Library.String pSearchOption, _.Library.String pTags, _.Library.Integer pLimit, _.Library.Status pSC)
 
_.Library.Float Rank (_.Library.RawString pRecordID, _.Library.String pSearchString, _.Library.String pSearchOption)
 
_.Library.String StripCharacters (_.Library.String pWord)
 Utility method stripping punctuation characters from the start and end of a word, according to. More...
 
_.Library.String StrippedEntityId (_.Library.String pEntity)
 Returns the Entity ID for pEntity, after stripping off any punctuation at the start and end of. More...
 
_.Library.String StrippedWordId (_.Library.String pWord)
 Returns the Word ID for pWord, after stripping off any punctuation at the start and end of. More...
 
- Static Public Member Functions inherited from Minimal
 DeleteIndex (_.Library.RawString pID, _.Library.Binary pArg)
 Deletes the iFind index for the row.
 
_.Library.RegisteredObject Embedded ()
 Return an instance of the embedded Find class, initialized with the index' parameters.
 
_.Library.Binary Find (_.Library.Binary pSearch, _.Library.Integer pOption, _.Library.String pLanguage, _.Library.String pSynonymOption)
 Searches for matches based on the iFind index. More...
 
 InsertIndex (_.Library.RawString pID, _.Library.Binary pArg)
 Inserts the iFind index for the row. More...
 
_.Library.String Normalize (_.Library.String pQuery, _.Library.String pLanguage)
 This method will normalize the query of iFind.Find.Basic based on the dictionary defined iFind.Index.Basic.
 
 PurgeIndex ()
 Purges the iFind index.
 
 UpdateIndex (_.Library.RawString pID, _.Library.Binary pArg)
 Updates the iFind index for the row.
 
- Static Public Member Functions inherited from FunctionalIndex
 DeleteIndex (_.Library.RawString pID, _.Library.Binary pArg)
 This method is invoked when an existing instance of a class is deleted.
 
 InsertIndex (_.Library.RawString pID, _.Library.Binary pArg)
 This method is invoked when a new instance of a class is inserted into the database.
 
 SegmentFinalize (_.Library.RawString pIndexBuffer, _.Library.RawString pStartID, _.Library.RawString pEndID)
 This method is called when the index builder is finalizing a segment. More...
 
 SegmentInitialize (_.Library.RawString pIndexBuffer, _.Library.RawString pStartID, _.Library.RawString pEndID)
 This method is called by the parallel index build to initialize an index segment when constructing. More...
 
 UpdateIndex (_.Library.RawString pID, _.Library.Binary pArg)
 This method is invoked when an existing instance of a class is updated.
 

Static Public Attributes

 KEEPCHARS = None
 
 RANKERCLASS = None
 
- Static Public Attributes inherited from Minimal
 IFINDADVANCEDSQLPREFIX = None
 
 IFINDMAPPINGS = None
 
 IFINDSHAREDDATALOCATION = None
 This parameter enables specifying whether words, entities and similar data should be written. More...
 
 IGNOREPUNCTUATION = None
 
 INDEXOPTION = None
 Specific indexing options to use when processing records. More...
 
 LANGUAGE = None
 Language to use when indexing records. More...
 
 LOWER = None
 Whether or not to convert content to lowercase before indexing. More...
 
 STEMMINGCONFIG = None
 
 SUPPORTSSHARDING = None
 This parameter can be set to 1 if the implementation of the filing interface and the SQL query interface can be. More...
 
 TRANSFORMATIONSPEC = None
 
 USERDICTIONARY = None
 
- Static Public Attributes inherited from FunctionalIndex
 SUPPORTSSHARDING = None
 This parameter can be set to 1 if the implementation of the filing interface and the SQL query interface can be. More...
 

Detailed Description

This index class provides text search capabilities to perform word-level searches through text in the String or Stream properties being indexed, for persistent classes using default storage.

Defining an iFind index

An iFind index can be defined in the class as follows:

Class ThePackage.MyClass Extends Persistent { Property MyStringProperty As String;

Index MyBasicIndex On (MyStringProperty) As iFind.Index.Basic; }

A number of parameters can be configured in order to refine the indexing behavior, such as whether to support case-sensitive search (<parameter>LOWER</parameter>), which language to use when indexing the text (<parameter>LANGUAGE</parameter>) or whether to enable stemming or decompounding (<parameter>INDEXOPTION</parameter>).

Querying an iFind index

Classes with an iFind index can subsequently be queried in SQL using the following syntax:

SELECT * FROM ThePackage.MyClass WHERE ID FIND search_index(MyBasicIndex, 'interesting')

This will return all the records containing the word "interesting". The following table lists a few sample search strings illustrating more advanced iFind search syntax.

Search stringWhat will be retrieved
structureAll records containing the word "structure"
logical structureAll records containing both the words "logical" and "structure" (implicit AND)
logical structure*Same, but with anything that starts with "structure" (wildcard search)
"logical structure"All records containing the word "structure" right behind "logical" (positional search)
"logical ? structure"All records containing the words "logical" and "structure" with exactly one word in between (positional search)
"logical [0-5] structure"Positional again, but with up to 5 words between
[logical, structure, 5]"</td><td>All records containing the words "logical" and "structure", but with up to 5 words between</td></tr> <tr><td width="250">[logical structure, diagram, 3-6]"All records containing the phrase "logical structure" and the word "diagram" again, with between 3 and 6 words between

It's also possible to use AND, OR and NOT, as well as parentheses to combine words into more complex search strings, other than the implicit AND which is the default behavior for multi-word search:

Search stringWhat will be retrieved
FixedAll records containing the word "fixed"
Fixed and storedAll records containing "fixed" and "stored"
Fixed and not storedAll records containing "fixed" but not "stored"
Fixed and not "stored procedure"All records containing "fixed" but not the positional string "stored procedure"
fixed and ("stored procedure" or "default parameters")All records containing "fixed" and either "stored procedure" or "default parameters"
Fixed and \notAll records containing the words "fixed" and "not"
Fixed \and \notAll records containing "fixed", "and" and "not"
not generatedAll records not containing "generated"
\not generatedImplicit AND of "not" and "generated"

Besides the name of the iFind index and the search string, the search_index() function supports two more optional parameters:

search_index(index_name, search_string [, search_option [, search_language]]

The search_option defines whether to search for exact occurrences of words in the search string (search_option=0), which is the default, to look for words that correspond to the same "normalized" form, based on a particular transformation. For example, stemming will normalize conjugated words to their base form and allow you to search for any conjugated form that corresponds to the same base form. Similarly, decompounding will normalize words even further by splitting up compound words in the atomic words it consists of (see also <class>iKnow.Stemming.DecompoundUtils</class>). The following values can be used for search_option:

  • search_option = 0 will perform a regular search, without any transformations. This is the default.
  • search_option = 1 is a shorthand for stemmed search, using the default stemmer for the current language (see also <class>iKnow.Stemmer</class>), optionally overridden by the <parameter>STEMMINGCONFIG</parameter>
  • search_option = 2 is a shorthand for decompounded search, relying on the same settings as stemming described in the previous bullet
  • search_option = 3 is a shorthand for fuzzy search, which will match any word that has at most 2 characters differing from the search term. (Note that this is not a transformation, strictly speaking).
  • search_option = '3:n' will also perform fuzzy search, but the maximum edit distance (different characters) is now n
  • search_option = 4 will perform a regular expression search
  • search_option = '*' is a shorthand for searching based on all the transformations defined for this index
  • search_option = 'string' will perform the tranformation identified by string (see also <parameter>TRANSFORMATIONSPEC</parameter>)

Which values are available for a given index depends on the values of the <parameter>INDEXOPTION</parameter> or <parameter>TRANSFORMATIONSPEC</parameter> parameters.

The search_language argument enables filtering records to those in a particular language, in cases where the indexed property contains text in multiple languages (<parameter>LANGUAGE</parameter> = "*"). This language is also passed on to an eventual word transformation method when search_option != 0.

If the <parameter>IFINDMAPPINGS</parameter> index is set to 1, the following additional SQL projections will be generated:

  • [class_name]_[index_name]_WordSpread: stores the total number of records in which this word appears in this index. See also <class>iFind.Index.AbstractWordSpread</class>.
  • [class_name]_[index_name]_WordPos stores which word occurs at which position in a record, so it can be joined to the AttributePos table. See also <class>iFind.Index.AbstractWordPos</class>.

Member Function Documentation

◆ Highlight()

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

This SQL procedure returns the text indexed by pRecordID, in which all matches of the

supplied pSearchString are highlighted using pTags.

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

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.

◆ Rank()

_.Library.Float Rank ( _.Library.RawString  pRecordID,
_.Library.String  pSearchString,
_.Library.String  pSearchOption 
)
static

This SQL procedure returns the score expressing how well the record identified by pRecordID

matches pSearchString, based on the ranking algorithm defined by <parameter>RANKERCLASS</parameter>.

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

pSearchOption can be used as in other iFind search operations, for example to also accept fuzzy matches or stem matches when calculating the rank score.

◆ StripCharacters()

_.Library.String StripCharacters ( _.Library.String  pWord)
static

Utility method stripping punctuation characters from the start and end of a word, according to.

the value of the <parameter>KEEPCHARS</parameter> index parameter for this index.

◆ StrippedEntityId()

_.Library.String StrippedEntityId ( _.Library.String  pEntity)
static

Returns the Entity ID for pEntity, after stripping off any punctuation at the start and end of.

the words making up the entity, according to the value of <parameter>KEEPCHARS</parameter> for this index.

◆ StrippedWordId()

_.Library.String StrippedWordId ( _.Library.String  pWord)
static

Returns the Word ID for pWord, after stripping off any punctuation at the start and end of.

the word, according to the value of <parameter>KEEPCHARS</parameter> for this index.

Member Data Documentation

◆ KEEPCHARS

KEEPCHARS = None
static

This parameter controls which characters are retained at the start and end of a word when calculating

the "stripped" version of a word that will be indexed along with the original word as it appeared in the text.

This parameter only applies if <parameter>IGNOREPUNCTUATION</parameter> is set to false (the default for Basic, Semantic and Analytic indices).

◆ RANKERCLASS

RANKERCLASS = None
static

The <class>iFind.Rank.Abstract</class> implementation to use for ranking search results

using the auto-generated rank SQL procedure "[package name].[class name]_[index name]Rank"