FacetFilter Class Methods
In this section, the FacetFilter class methods are presented in alphabetical order.
Syntax
clearFacetSorting()
Description
Use this method to reset facet sorting on all levels to default sorting values.
Parameters
None.
Returns
None.
Syntax
FacetFilter(FacetName, Path)
Description
Use this constructor to instantiate a FacetFilter object for a specific facet to indicate the facet and path.
Parameters
Field or Control |
Definition |
---|---|
FacetName |
Specifies the name of the facet as a string. |
Path |
Specifies the value of the facet as a string. |
Returns
A FacetFilter object.
Example
The following examples demonstrate four ways to create a facet filter:
Use the SearchCategory class to return the initial list of facet filters with empty paths as an array of FacetFilter objects:
Local PT_SEARCH:SearchCategory &srchCat = create PT_SEARCH:SearchCategory("MY_SRCH_CAT"); &qry.Categories = CreateArray(&srchCat); &qry.FacetFilters = &srchCat.GetFacetFilters();
When requesting a specific facet for the first time, specify an empty string for the path:
Local PT_SEARCH:FacetFilter &facetFilter = create PT_SEARCH:FacetFilter("LOCATION","")
When the facet is hierarchical, specify the hierarchy in the path. For example, the LOCATION facet could have a hierarchy of country/state/city. To filter by country, use the following filter:
Local PT_SEARCH:FacetFilter &facetFilter = create PT_SEARCH:FacetFilter("LOCATION","USA")
To filter by state, use the following filter:
Local PT_SEARCH:FacetFilter &facetFilter = create PT_SEARCH:FacetFilter("LOCATION","USA/CA")
Syntax
getFacetSortings()
Description
Use this method to return a map of facet sortings as a StringMap object. If no facet sorting is defined, the map will be of size 0.
Parameters
None.
Returns
A StringMap Object.
Syntax
getFacetValuesSortType(level)
Description
Use this method to return the sort type for the specified level.
Parameters
Field or Control |
Definition |
---|---|
level |
Specifies the level in the facet path hierarchy as an integer. For facets without a path hierarchy, specify 1. |
Returns
A string value.
Syntax
hasCustomFacetSorting(level)
Description
Use this method to verify whether the default facet sorting has been overridden for the specified level.
Parameters
Field or Control |
Definition |
---|---|
level |
Specifies the level in the facet path hierarchy as an integer. For facets without a path hierarchy, specify 1. |
Returns
A Boolean value. True if facet sorting has been overridden for the specified level, False otherwise.
Syntax
sortFacetValuesAlphabetically(level, sort_ascending)
Description
Use this method to sort facet values for the specified level alphabetically.
Parameters
Field or Control |
Definition |
---|---|
level |
Specifies the level in the facet path hierarchy as an integer. For facets without a path hierarchy, specify 1. |
sort_ascending |
Specifies the sorting order: True for ascending order and False for descending order sorting. |
Returns
None.
Syntax
sortFacetValuesByDocumentCount(level, sort_ascending)
Description
Use this method to sort facet values for the specified level by the document count.
Parameters
Field or Control |
Definition |
---|---|
level |
Specifies the level in the facet patch hierarchy as an integer. For facets without a path hierarchy, specify 1. |
sort_ascending |
Specifies the sorting order: True for ascending order and False for descending order sorting. |
Returns
None.
Syntax
sortFacetValuesByType(level, sort_type)
Description
Use this method to define the sort type by specifying a string value. This method can be used instead of sortFacetValuesByDocumentCount, sortFacetValuesAlphabetically, and sortFacetValuesNumericallyof methods.
Parameters
Field or Control |
Definition |
---|---|
level |
Specify the level in the facet path hierarchy. For facets without a path hierarchy, specify 1. |
sort_type |
Specifies the sort type as one of the following string values:
|
Returns
None.
Syntax
sortFacetValuesNumerically(level, sort_ascending)
Description
Use this method to sort facet values numerically for the specified level. If the facet values are not numbers, this method will cause an error when it is executed at run time.
Parameters
Field or Control |
Definition |
---|---|
level |
Specifies the level in the facet path hierarchy as an integer. For facets without a path hierarchy, specify 1. |
sort_ascending |
Specifies the sorting order as a Boolean value: True for ascending order and False for descending order sorting. |
Returns
None.