SearchFilterGenerator Class Properties

In this section, the SearchFilterGenerator class property is discussed.

Description

Use this property to boost the score of a keyword without applying a filter. Because a filter is not applied, you may obtain more results, but the score of a keyword is boosted when the keyword match is found.

You may also use this property along with valid filters, which can be applied on some fields to narrow the search results.

Example

The following code snippet applies a filter and boosts the score of the keyword when the keyword match is found.

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

/* For applying query filter- These filters are applied to the search query to narrow down the result set */
If &fg.MatchAllReturnTrue() Then
   &fg.EqualsString("BUSINESS_UNIT", "US001");
   &fg.ContainsWord("NAME", "Alex");
   &fg.EndMatchAll();
End-If;
&fg.SetQueryFilter(&qry);

/* For boosting score for the match of a given keyword */
Local PT_SEARCH:SearchFilterGenerator &fgBoost = create PT_SEARCH:SearchFilterGenerator();
&fgBoost.BoostWithoutFilter = True;
If &fgBoost.MatchAnyReturnTrue() Then
   &fgBoost.EqualsString("", "FPNIR878");    
   &fgBoost.BoostFilterScore(0.01);
   &fgBoost.ContainsWord("", "support");
   &fgBoost.BoostFilterScore(0.05);
   &fgBoost.EndMatchAny();
End-If;
&fgBoost.setBoostModeSum();
&fgBoost.setQueryScoreBoostSum();
&fgBoost.SetQueryFilter(&qry);