SearchFilterGenerator Class Methods

In this section, the SearchFilterGenerator class methods are presented in alphabetical order.

Syntax

AddQueryFilter(&srch_qry)

Description

Use this method to push the composite query filter onto the array of filters in the SearchQuery object.

Parameters

Parameter

Description

&srch_qry

Specifies the query as a SearchQuery object.

Returns

None.

Syntax

AfterDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates after the specified value.

Note: The AfterDate method is equivalent to the AfterDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

AfterDateTime(srch_field, datetime)

Description

Use the AfterDateTime method to generate a datetime filter on the specified search field for dates after the specified value.

Note: The AfterDateTime method is equivalent to the AfterDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

AfterDateValue(srch_field, date)

Description

Use the AfterDateValue method to generate a date filter on the specified search field for dates after the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

AppendFilter(&SearchFilter)

Description

Use the AppendFilter method to append the filter from one SearchFilterGenerator object to another SearchFilterGenerator object.

Parameters

Parameter

Description

&SearchFilter

Specifies the filter as a SearchFilter object.

Returns

None.

Example

import PT_SEARCH:SearchFilter;
import PT_SEARCH:SearchFilterGenerator;

Local PT_SEARCH:SearchFilterGenerator &SFG1 = create PT_SEARCH:SearchFilterGenerator();
Local PT_SEARCH:SearchFilterGenerator &SFG2 = create PT_SEARCH:SearchFilterGenerator();
Local PT_SEARCH:SearchFilter &Flt = create PT_SEARCH:SearchFilter();

&Flt = &SFG2.GetFilter();
&SFG1.AppendFilter(&Flt);

Syntax

BeforeDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates before the specified value.

Note: The BeforeDate method is equivalent to the BeforeDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

BeforeDateTime(srch_field, datetime)

Description

Use the BeforeDateTime method to generate a datetime filter on the specified search field for dates before the specified value.

Note: The BeforeDateTime method is equivalent to the BeforeDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

BeforeDateValue(srch_field, date)

Description

Use the BeforeDateValue method to generate a date filter on the specified search field for dates before the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

BoostCompositeFilterScore(boost)

Description

Use the BoostCompositeFilterScore method to boost the score of a combination of filters together. Using this method in the formation of a search filter indicates that the score of the search results is boosted from the default scoring used by the search engine. When two or more score boosts have been applied to individual search filters, then specify the boost mode. Otherwise, the default boost mode is MIN, which is equivalent to executing the setBoostModeMinimum method.

Note: The PeopleSoft Search Framework scores results from 0-100, meaning the maximum score for a search result row is 100.

Parameters

Parameter

Description

boost

Specifies the score boost as number value from 0.00 to 1.00 (that is, as a percentage). For example, if a boost of 2 points is desired, set boost to 0.02.

Returns

None.

Example

In the following example, the score returned by the search engine is boosted by 2 points if either (or both) of the filters returns a result:

If &fg.MatchAnyReturnTrue() Then
   &fg.ContainsWord("QE_YEAR_H", "07");
   &fg.ContainsWord("QE_STATUS", "Draft");
   &fg.BoostCompositeFilterScore(0.02);
   &fg.EndMatchAny();
End-If;

Syntax

BoostFilterScore(boost)

Description

Use the BoostFilterScore method to boost the score of specific filter match. Using this method in the formation of a search filter indicates that the score of the search results is boosted from the default scoring used by the search engine. When two or more score boosts have been applied to individual search filters, then specify the boost mode. Otherwise, the default boost mode is MIN, which is equivalent to executing the setBoostModeMinimum method.

You may also use the BoostFilterScore method to boost the score of a keyword without performing a filter match. In this case, you should only pass the keyword to the BoostFilterScore method; do not pass the field name. If the keyword exists anywhere in the document, the score of the document is boosted by the specified score. Alternatively, you may use the BoostWithoutFilter property.

Note: The PeopleSoft Search Framework scores results from 0-100, meaning the maximum score for a search result row is 100.

Parameters

Parameter

Description

boost

Specifies the score boost as number value from 0.00 to 1.00 (that is, as a percentage). For example, if a boost of 2 points is desired, set boost to 0.02.

Returns

None.

Example

In the following example, filter match is performed and the score returned by the search engine is boosted by 2 points:

If &fg.MatchAllReturnTrue() Then
   &fg.ContainsWord("DEPTNAME", "support");
   &fg.BoostFilterScore(0.02);
   &fg.EndMatchAll();
End-If;

In the following example, only the keyword is passed to the method; not the field name. The score of the result is boosted by 2 points if the specified keyword finds a match anywhere in the document.

If &fg.MatchAllReturnTrue() Then
   &fg.ContainsWord("", "support");
   &fg.BoostFilterScore(0.02);
   &fg.EndMatchAll();
End-If;

Syntax

ContainsKeyWords(srch_field, words)

Description

Use the ContainsKeyWords method to generate a string filter that matches strings. Unlike the ContainsWord method, this method allows to supply logical operator (& or |) to separate words within the words parameter. If no operator is specified, then the default & operator is used.

Important! This method cannot be used in conjunction with any of the score boosting methods.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

words

Specifies the keywords as a string.

Returns

None.

Example

In the following example, the search filter returns results that match either apples or oranges:

&SFG.ContainsKeyWords(&sAttrName," apples | oranges");

In the following example, the search filter returns results that match both apples and oranges:

&SFG.ContainsKeyWords(&sAttrName," apples & oranges");

Syntax

ContainsPartialWord(srch_field, fragment)

Description

Use this method to generate a string filter that matches strings containing a word that begins with the specified partial word.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

fragment

Specifies the word fragment as a string.

Returns

None.

Syntax

ContainsPhrase(srch_field, phrase)

Description

Use this method to generate a string filter that matches strings containing the exact phrase.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

phrase

Specifies the exact phrase as a string.

Returns

None.

Syntax

ContainsWord(srch_field, word)

Description

Use the ContainsWord method to generate a string filter that matches strings containing the exact word or words. Words are separated by spaces and the logical and operator is implied; explicit logical operators are not supported between the words. This method forms the filter to find a match on all the words in the word parameter.

Note: While the word parameter can include one or more words, this method differs from the ContainsPhrase method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

word

Specifies the exact word or words as a string.

Returns

None.

Example

Consider a document that includes the following sentence:

Apples are tastier than oranges.

The following use of ContainsWord will return a match.

&fg.ContainsWord("LONG_TEXT", "apples oranges");

However, the following use of ContainsPhrase will not return a match.

&fg.ContainsPhrase("LONG_TEXT", "apples oranges");

Syntax

DateToDatetime(date)

Description

Use this method to convert a date value to datetime value. The time portion of the value is set to 12:00:00.

Parameters

Parameter

Description

date

Specifies the date value to be converted.

Returns

A datetime value.

Syntax

EndMatchAll()

Description

Use this method to mark the end of a temporary composite search filter initiated by MatchAll or MatchAllReturnTrue. This temporary composite search filter is then pushed onto the array of filters for the preceding search filter.

Parameters

None.

Returns

None.

Syntax

EndMatchAny()

Description

Use this method to mark the end of a temporary composite search filter initiated by MatchAny or MatchAnyReturnTrue. This temporary composite search filter is then pushed onto the array of filters for the preceding search filter.

Parameters

None.

Returns

None.

Syntax

EqualsDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates equal to the specified value.

Note: The EqualsDate method is equivalent to the EqualsDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

EqualsDateTime(srch_field, datetime)

Description

Use the EqualsDateTime method to generate a datetime filter on the specified search field for dates equal to the specified value.

Note: The EqualsDateTime method is equivalent to the EqualsDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

EqualsDateValue(srch_field, date)

Description

Use the EqualsDateValue method to generate a date filter on the specified search field for dates equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

EqualsNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

EqualsString(srch_field, string)

Description

Use this method to generate a string filter on the specified search field for strings equal to the specified value.

Important! This method cannot be used in conjunction with any of the score boosting methods.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

string

Specifies the search string as a String value.

Returns

None.

Syntax

GetFilter()

Description

Use the GetFilter method to return the root filter (the first element of the filter array) for the specified SearchFilterGenerator object.

Parameters

None.

Returns

A SearchFilter object.

Example

&Flt = &SFG2.GetFilter();

Syntax

GreaterThanEqualsNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers greater than or equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

GreaterThanNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers greater than the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

LessThanEqualsNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers less than or equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

LessThanNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers less than the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

MatchAll()

Description

Use this method to initiate a temporary composite search filter using the & filter connector between filters.

Parameters

None.

Returns

None.

Example

In the following example, the composite filter consists of two filters joined by the & filter connector:

&fg.MatchAll();
&fg.NotEqualsString("a", "x");
&fg.NotEqualsString("b", "y");
&fg.EndMatchAll();

Syntax

MatchAllReturnTrue()

Description

Use this method to initiate a temporary composite search filter using the & filter connector between filters. Since successful execution of this method returns True, you can use this method in logical expressions.

Parameters

None.

Returns

A Boolean value.

Example

In the following example, the composite filter consists of two filters joined by the & filter connector:

If &fg.MatchAllReturnTrue() Then
   &fg.NotEqualsString("a", "x");
   &fg.NotEqualsString("b", "y");
   &fg.EndMatchAll();
End-If;

Syntax

MatchAny( )

Description

Use this method to initiate a temporary composite search filter using the | filter connector between filters.

Parameters

None.

Returns

None.

Syntax

MatchAnyReturnTrue( )

Description

Use this method to initiate a temporary composite search filter using the | filter connector between filters. Since successful execution of this method returns True, you can use this method in logical expressions.

Parameters

None.

Returns

A Boolean value.

Example

In the following example, the final composite filter consists of two composite filters each consisting of two filters. The individual filters and the composite filters are all joined by the | filter connector:

If &fg.MatchAnyReturnTrue() Then

   If &fg.MatchAnyReturnTrue() Then
      &fg.LessThanNumber("c", 4);
      &fg.GreaterThanNumber("c", 5);
      &fg.EndMatchAny();
   End-If;

   If &fg.MatchAnyReturnTrue() Then
      &fg.ContainsWord("d", "x");
      &fg.EqualsString("e", "z");
      &fg.EndMatchAny();
   End-If;

   &fg.EndMatchAny();

Syntax

NotContainsWord(srch_field, word)

Description

Use the NotContainsWord method to generate a string filter that does not match strings containing the exact word or words. Words are separated by spaces and the logical and operator is implied; explicit logical operators are not supported between the words. This method forms the filter to find a match on all the words in the word parameter.

Note: While the word parameter can include one or more words, this parameter is not equivalent to a phrase.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

word

Specifies the exact word or words as a string.

Returns

None.

Example

Consider a document that includes the following sentence:

Apples are tastier than oranges.

The following use of NotContainsWord will exclude this document.

&fg.NotContainsWord("LONG_TEXT", "apples oranges");

Syntax

NotEqualsDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates not equal to the specified value.

Note: The NotEqualsDate method is equivalent to the NotEqualsDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

NotEqualsDateTime(srch_field, datetime)

Description

Use the NotEqualsDateTime method to generate a datetime filter on the specified search field for dates not equal to the specified value.

Note: The NotEqualsDateTime method is equivalent to the NotEqualsDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

NotEqualsDateValue(srch_field, date)

Description

Use the NotEqualsDateValue method to generate a date filter on the specified search field for dates not equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

NotEqualsNumber(srch_field, number)

Description

Use this method to generate a numeric filter on the specified search field for numbers not equal to the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

number

Specifies the search value as a Number value.

Returns

None.

Syntax

NotEqualsString(srch_field, string)

Description

Use this method to generate a string filter on the specified search field for strings not equal to the specified value.

Important! This method cannot be used in conjunction with any of the score boosting methods.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

string

Specifies the search string as a String value.

Returns

None.

Syntax

OnOrAfterDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates on or after the specified value.

Note: The OnOrAfterDate method is equivalent to the OnOrAfterDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

OnOrAfterDateTime(srch_field, datetime)

Description

Use the OnOrAfterDateTime method to generate a datetime filter on the specified search field for dates on or after the specified value.

Note: The OnOrAfterDateTime method is equivalent to the OnOrAfterDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

OnOrAfterDateValue(srch_field, date)

Description

Use the OnOrAfterDateValue method to generate a date filter on the specified search field for dates on or after the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

OnOrBeforeDate(srch_field, datetime)

Description

Use this method to generate a datetime filter on the specified search field for dates on or before the specified value.

Note: The OnOrBeforeDate method is equivalent to the OnOrBeforeDateTime method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

OnOrBeforeDateTime(srch_field, datetime)

Description

Use the OnOrBeforeDateTime method to generate a datetime filter on the specified search field for dates on or before the specified value.

Note: The OnOrBeforeDateTime method is equivalent to the OnOrBeforeDate method.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

datetime

Specifies the date as a datetime value.

Returns

None.

Syntax

OnOrBeforeDateValue(srch_field, date)

Description

Use the OnOrBeforeDateValue method to generate a date filter on the specified search field for dates on or before the specified value.

Parameters

Parameter

Description

srch_field

Specifies the search field name as a string.

date

Specifies the date as a date value.

Returns

None.

Syntax

SearchFilterGenerator()

Description

Use this constructor to instantiate a SearchFilterGenerator object. Similar to the MatchAll method, the composite filter is initialized with the & filter connector.

Parameters

None.

Returns

None.

Example

Instantiate the SearchFilterGenerator class as follows:

Local PT_SEARCH:SearchFilterGenerator &fg = create PT_SEARCH:SearchFilterGenerator();

Syntax

setBoostMode(mode)

Description

Use the setBoostMode method to specify the computation to be performed to determine the final boost score when two or more score boosts have been applied to individual search filters.

Parameters

Parameter

Description

mode

Specifies the boost mode as a string value:

  • “ADD” – To set the computed boost to the sum of all the matches. Equivalent to setBoostModeSum.

  • “AVG” – To set the computed boost to the average of all of the matches. Equivalent to setBoostModeAverage.

  • “MAX” – To set the computed boost to the maximum score from all of the matches. Equivalent to setBoostModeMaximum.

  • “MIN” – To set the computed boost to the minimum score from all of the matches. Equivalent to setBoostModeMinimum.

    Note: MIN is the default boost mode.

Returns

None.

Example

In the following example, if there is a match for both filters, then the score would be boosted by 5 points, which is the sum of the score boosts; otherwise, if just one filter is matched, then the score is boosted by that match alone:

If &fg.MatchAnyReturnTrue() Then
   &fg.ContainsWord("DEPTNAME", "support");
   &fg.BoostFilterScore(0.02);
   &fg.ContainsWord("QE_STATUS", "open");
   &fg.BoostFilterScore(0.03);
   &fg.EndMatchAny();
   &fg.setBoostMode("ADD");
   Rem &fg.setBoostModeSum(); /* Equivalent mode */
End-If;

Syntax

setBoostModeAverage()

Description

Use the setBoostModeAverage method to set the computed boost to the average of all of the matches.

Parameters

None.

Returns

None.

Syntax

setBoostModeMaximum()

Description

Use the setBoostModeMaximum method to set the computed boost to the maximum score from all of the matches.

Parameters

None.

Returns

None.

Syntax

setBoostModeMinimum()

Description

Use the setBoostModeMinimum method to set the computed boost to the minimum score from all of the matches.

Note: Minimum is the default boost mode.

Parameters

None.

Returns

None.

Syntax

setBoostModeSum()

Description

Use the setBoostModeSum method to set the computed boost to the sum of all of the matches.

Parameters

None.

Returns

None.

Example

In the following example, if there is a match for both filters, then the score would be boosted by 5 points, which is the sum of the score boosts; otherwise, if just one filter is matched, then the score is boosted by that match alone:

If &fg.MatchAnyReturnTrue() Then
   &fg.ContainsWord("DEPTNAME", "support");
   &fg.BoostFilterScore(0.02);
   &fg.ContainsWord("QE_STATUS", "open");
   &fg.BoostFilterScore(0.03);
   &fg.EndMatchAny();
   &fg.setBoostModeSum();
   Rem &fg.setBoostMode("ADD"); /* Equivalent mode */
End-If;

Syntax

SetQueryFilter(&srch_qry)

Description

Use this method to set the composite query filter as the array of filters for the SearchQuery object.

Parameters

Parameter

Description

&srch_qry

Specifies the query as a SearchQuery object.

Returns

None.

Syntax

StringDateToDatetime(str_date)

Description

Use this method to convert a string value representing a date to datetime value. The time portion of the value is set to 12:00:00.

Parameters

Parameter

Description

str_date

Specifies the string value representing a date to be converted.

Returns

A datetime value.