This chapter provides an overview of the PeopleSoft Search Framework classes and discusses:
Differences between the PeopleSoft Search Framework classes and Verity search classes.
Instantiating a SearchQuery object.
Processing search results.
Exception handling.
PeopleSoft Search Framework classes reference.
Additional examples.
In previous PeopleTools releases, search functionality was provided in a non-declarative fashion in which search engine indexes were built using custom PeopleCode and Application Engine programs. Each PeopleSoft application used a unique method for creating and maintaining search artifacts like collections and indexes—all of which required search engine-specific calls, commands, syntax, and so on.
The PeopleSoft Search Framework enables application developers and implementation teams to create search artifacts in a declarative manner and to deploy and maintain search indexes using one standard interface, regardless of PeopleSoft application.
The PeopleSoft Search Framework consists of PeopleSoft components (pages and records provided by PeopleTools), which provide a centralized interface for configuring PeopleSoft integration with the search engine, creating search artifacts such as search definitions and search categories, and building and maintaining search indexes.
In addition to the user interface, the PeopleSoft Search Framework is supported by several PeopleCode application classes including PT_SEARCH and several PTSF application packages. The PT_SEARCH application package provides the administration and query service interfaces for integration with web service based free-text search engines. The root package comprises a factory class, interfaces, superclasses, and implementations for classes that are not dependent on a specific search engine.
See Also
PeopleTools 8.52: PeopleSoft Search Technology PeopleBook
The Verity search classes were implemented specifically to support PeopleTools integration with the Verity search engine. Conversely, the PeopleSoft Search Framework was developed to provide an interaction layer that is independent of any specific search engine. In particular, the PeopleSoft Search Framework classes documented in this chapter are general purpose classes not associated with any particular search engine.
The PeopleSoft Search Framework was designed to integrate with any number of free-text search solutions, each of which could be implemented as a subpackage under the PT_SEARCH application package. At this time, the only search solution supported by PeopleTools “as delivered” is Oracle Secure Enterprise Search (SES), which is implemented in the PT_SEARCH:SESIMPL subpackage.
The Verity search objects are implemented as PeopleCode built-in objects. PeopleSoft Search Framework objects are implemented through an open source PeopleCode application package. In both cases, the primary interaction class is the SearchQuery class. With Verity, a SearchQuery object is instantiated using the PortalRegistry or Session built-in classes. With the PeopleSoft Search Framework, a SearchQuery object is instantiated from a SearchQueryService object. The SearchQueryService object itself is created using the SearchFactory class.
See Also
Instantiating a SearchQuery Object
With the PeopleSoft Search Framework, a SearchQuery object is instantiated by instantiating a SearchFactory object, which is used to create a SearchQueryService object. The SearchQuery object is then instantiated from the SearchQueryService.
The high-level program flow is as follows:
import PT_SEARCH:SearchFactory; import PT_SEARCH:SearchQueryService; import PT_SEARCH:SearchQuery; Local PT_SEARCH:SearchFactory &factory = create PT_SEARCH:SearchFactory(); Local PT_SEARCH:SearchQueryService &svc = &factory.CreateQueryService("default"); Local PT_SEARCH:SearchQuery &srchQuery = &svc.CreateQuery();
The PeopleSoft Search Framework classes are application classes, not built-in classes, like Rowset, Field, Record, and so on. Before you can use these classes in your PeopleCode program, you must import them into your program.
An import statement either names a particular application class or imports all the classes in a package.
Using the asterisks after the package name makes all the application classes directly contained in the named package available. Application classes contained in subpackages of the named package are not made available.
The following example code demonstrates how to retrieve properties of the SearchResultCollection and how to iterate over the results in the collection:
Import the application package.
import PT_SEARCH:*;
Create an instance of SearchQueryService and SearchFactory.
Local PT_SEARCH:SearchFactory &factory = create PT_SEARCH:SearchFactory(); Local PT_SEARCH:SearchQueryService &svc = &factory.CreateQueryService("default");
Instantiate the SearchQuery object.
Local PT_SEARCH:SearchQuery &srchQuery = &svc.CreateQuery();
Initialize the search query by setting properties.
&srchQuery.QueryText = "some text"; &srchQuery.Language = &lang_cd; &srchQuery.MarkDuplicates = False; &srchQuery.RemoveDuplicates = False;
Execute the search query.
Use the Execute method and specify two integer parameters: start determines the index of the first document, size determines the number of search documents to return "page" of results.
Local number &start = 1; Local number &size = 10; Local PT_SEARCH:SearchResultCollection &results; &results = &srchQuery.Execute(&start, &size);
Process the search query results
The search query returns a SearchResultCollection. To process this collection: The SearchResultCollection contains SearchResult objects. Each SearchResult has its own methods to access its attributes such as Title, Summary, URL Link, and so on. Each SearchResult also optionally has custom attributes that can be accessed through the SearchFieldCollection object.
Local number &i, &j; Local number &score; Local string &title; Local string &summary; Local datetime &lastMod; Local string &url; Local string &name; Local string &value; Rem - Get a couple return properties; Local number &docCount = &results.GetDocumentCount(); Local number &hitCount = &results.GetEstimatedHitCount(); Rem - Iterate through the search results; Local PT_SEARCH:SearchResult &curResult; Local PT_SEARCH:SearchFieldCollection &customs; For &i = 1 To &results.GetDocumentCount() &curResult = &results.Item(&i); &score = &curResult.GetScore(); &title = &curResult.GetTitle(); &summary = &curResult.GetSummary(); &lastMod = &curResult.GetLastModified(); &url = &curResult.GetUrlLink(); /* Do something with these result attributes */ Rem - Get the custom fields of the result if any; &customs = &curResult.GetCustomAttributes(); If (&customs <> Null) Then Rem - Iterate through custom fields of the result; For &j = 1 To &customs.Count() &name = &customs.Item(&j).Name; &value = &customs.Item(&j).Value; /* do something with the custom field */ End-For; End-If; End-For; Rem - Calculate the number of additional pages in the results; Local integer &pages; &pages = Idiv(&hitCount, &size); If Mod(&hitCount, &size) > 0 Then &pages = &pages + 1; End-If; Rem - Render the additional pages as links;
Get the page number for the next request.
Re-execute the search query to retrieve the next page. Increment start to the next page; then invoke the Execute method.
Rem - Get the requested page from the link clicked by the user; Rem - Store the value in the &req_page variable; Local integer &req_page; Rem - Calculate the new start value and re-execute the query; &start = (&req_page - 1) * &size + 1; &results = &srchQuery.Execute(&start, &size);
The preceding example returns the results in chunks, or pages, which provides better query performance than returning all results at once. However, you could elect to return all results in a single search query. In that case, you will need to consider the maximum number of results returned by the search engine. For example, when SES is the search provider, 200 is the default value for the maximum number of results. In this case, the Execute method would be invoked as follows to return all results at once:
Local number &start = 1; Local number &size = 200; Local PT_SEARCH:SearchResultCollection &results; &results = &srchQuery.Execute(&start, &size);
See Also
The PeopleSoft Search Framework uses the try/catch exception construct to handle special conditions that interrupt normal program execution. When special runtime conditions are encountered, the PeopleSoft Search Framework will construct and throw objects of the Exception class or some class derived from the Exception class. There are two main categories of PeopleSoft Search Framework exceptions:
Those thrown when the PeopleSoft Search Framework detects a special condition.
Those thrown when the search provider responds with anything other than what was expected for the given request.
The second category of exceptions is necessarily search engine specific since these are coming from the search provider. For example, there are two exception classes defined in the SESIMPL application subpackage: SESQueryServiceException and SESAdminServiceException. As the names imply, the first can be thrown by calls to the SearchQueryService methods and the second can be thrown by calls to the SearchAdminService methods. Both of these exception classes expose SOAPFaultCode and SOAPFaultString properties that are returned by SES. The SESAdminServiceException exposes additional properties which are defined in Appendix B of the Oracle Secure Enterprise Search Administration API Guide.
See http://download.oracle.com/docs/cd/E14507_01/apirefs.1112/e14133/errors.htm#sthref1501
Virtually all methods of all classes in the PeopleSoft Search Framework can throw an exception; therefore, Oracle recommends that you put all calls to the PeopleSoft Search Framework classes within try-catch blocks.
The following example builds on the previous example that processed search results. In this example, the results processing is augmented by try-catch exception handling:
import PT_SEARCH:*; import PT_SEARCH:SESIMPL:EXCEPTION:*; /* instantiate and initialize the query object */ /* ... */ /* execute the query */ Local PT_SEARCH:SearchResultCollection &results; try &results = &qry.Execute(&start, &size); catch PT_SEARCH:SESIMPL:EXCEPTION:SESQueryServiceException &sesEx MessageBox(0, "", 0, 0, "The search could not be perfomed."); MessageBox(0, "", 0, 0, "The Search Provider returned an error."); MessageBox(0, "", 0, 0, "SOAP fault: ", &sesEx.SoapFaultString); WriteToLog(0, &sesEx.SoapFaultCode); WriteToLog(0, &sesEx.SoapFaultString); Exit; catch Exception &psEx MessageBox(0, "", 0, 0, "The search could not be perfomed."); MessageBox(0, "", 0, 0, "Exception: ", &psEx.DefaultText); WriteToLog(0, &psEx.DefaultText); Exit; end-try; /* process the results */ try Local number &docCount = &results.GetDocumentCount(); Local number &hitCount = &results.GetEstimatedHitCount(); Local PT_SEARCH:SearchResult &curResult; Local PT_SEARCH:SearchFieldCollection &customs; For &i = 1 To &results.GetDocumentCount() &curResult = &results.Item(&i); &score = &curResult.GetScore(); &title = &curResult.GetTitle(); &summary = &curResult.GetSummary(); &lastMod = &curResult.GetLastModified(); &url = &curResult.GetUrlLink(); /* do something with the values */ &customs = &curResult.GetCustomAttributes(); If (&customs <> Null) Then /* iterate over custom fields of the result */ For &j = 1 To &customs.Count() &name = &customs.Item(&j).Name; &value = &customs.Item(&j).Value; /* do something with the name/value pair */ End-For; End-If; End-For; catch Exception &ex /* encountered an exception while processing results */ /* inspect the exception to determine appropriate action */ end-try;
See Also
This reference section documents the following classes from the PT_SEARCH application package:
FacetFilter class.
FacetNode class.
SearchAttribute class
SearchCategory class
SearchFactory class
SearchField class
SearchFieldCollection class
SearchFilter class
SearchQuery class
SearchQueryService class
SearchResult class
SearchResultCollection class
This reference section also documents the following classes from the PTSF_SECURITY application package: SearchAuthnQueryFilter class.
This section provides an overview of the FacetFilter class and discusses:
FacetFilter class methods.
FacetFilter class properties.
The FacetFilter class is used to filter the search results on one or more facet values. Facets are aspects, properties, or characteristics of a piece of data. In a PeopleSoft application, this could be PeopleSoft metadata (for example, SETID or business unit), or it could be any other attribute of the data. For example, job openings could be classified (faceted) by location, department or job family, working hours, pay scale, posting date, business unit, SETID, and so on. Facets allow for “filtered search” or “filtered navigation” of search results.
See Also
In this section, the FacetFilter class methods are presented in alphabetical order.
Syntax
FacetFilter(FacetName, Path)
Description
Use this constructor to instantiate a FacetFilter object for a specific facet to indicate the facet and path.
Parameters
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")
See Also
In this section, the FacetFilter class properties are presented in alphabetical order.
Description
Use this property to set or return the long description for the facet as a string. This description appears as the label for the facet in the user interface.
This property is read-write.
Description
Use this property to set or return the name of the facet as a string.
This property is read-write.
Description
Use this property to set or return the value for facet as a path string.
This property is read-write.
Example
The Path property is implicitly set to the value of the Path parameter supplied in the constructor for the FacetFilter class. In this example, the Path property is set to USA/CA:
&facetFilter = create PT_SEARCH:FacetFilter("LOCATION","USA/CA")
However, the Path property can also be explicitly set as in the following example:
&facetFilter.Path = "USA/CO/Denver";
This section provides an overview of the FacetNode class and discusses:
FacetNode class methods.
FacetNode class properties.
The FacetNode class extends the FacetFilter class and is used to return the list of facet node values along with other information about the facet nodes.
Facet nodes are used to render the list of facet values of a particular facet for a given search. This list of facet nodes is retrieved using GetFacetNodes method of the SearchResultCollection. Since a facet node is constructed with a facet path, this information can be used to create a facet filter indicating that the user has chosen to filter the results further based on the facet node.
See Also
In this section, the FacetNode class methods are presented in alphabetical order.
Syntax
addChild(&node)
Description
Use this method to add a child facet node to the current facet node.
Parameters
&node |
Specifies the child facet node as a FacetNode object. |
Returns
None.
Syntax
FacetNode(FacetName, NodeName, Path, DisplayValue, DocCount)
Description
Use this constructor to instantiate a FacetNode object for a specific facet.
Parameters
FacetName |
Specifies the name of the facet as a string and is used to refer to that member of the superclass. |
NodeName |
Specifies the name of this facet node as a string. |
Path |
Specifies the value of the facet as a string and is used to refer to that member of the superclass. |
DisplayValue |
Specifies the display value for this facet node as a string. |
DocCount |
Specifies an integer representing the number of documents that would be returned if this facet node were selected as a search filter. |
Returns
A FacetNode object.
Syntax
getChildNodes()
Description
Use this method to return an array of child nodes.
Parameters
None.
Returns
An array of FacetNode objects.
See Also
In this section, the FacetNode class properties are presented in alphabetical order.
Description
Use this property to set or return the display value for this facet node as a string.
This property is read-write.
Description
Use this property to set or return an integer representing the number of documents that would be returned if this facet node were selected as a search filter.
This property is read-write.
Description
Use this property to set or return the value of this facet node as a string.
This property is read-write.
The FacetName, FacetValue, and DisplayValue are all closely related. For example, consider the following facet filter: FacetFilter("LOCATION","USA"). These properties would have the following values:
FacetName: LOCATION
FacetValue: USA
DisplayValue: United States
See Also
Description
Use this property to set or return a Boolean value indicating whether this facet node has children.
This property is read-write.
This section provides an overview of the SearchAttribute class and discusses:
SearchAttribute class methods.
SearchAttribute class properties.
The SearchAttribute class represents a search attribute, which is an alias to a search query field. Search attributes enable you to hide the attribute name and query field name from the end user, who will see the search attribute display name.
An array of search attributes are returned using the GetAllAttributes, GetConfiguredFilterAttributes, GetNonConfiguredFilterAttributes, and GetRequestedAttributes methods of the SearchCategory class.
See Also
GetNonConfiguredFilterAttributes
In this section, the SearchAttribute class methods are presented in alphabetical order.
Syntax
SearchAttribute(Name, Type)
Description
Use this constructor to instantiate a SearchAttribute object for a specific attribute.
Parameters
Name |
Specifies the name of the attribute as a string . |
Type |
Specifies the type for this attribute as a one-character string. The values for Type can be as follows:
|
Returns
A SearchAttribute object.
In this section, the SearchAttribute class properties are presented in alphabetical order.
Description
Use this property to set or return a string to be used as the display name for this attribute within the user interface.
This property is read-write.
Description
Use this property to set or return a string representing the name of this search attribute.
This property is read-write.
Description
Use this property to set or return a one-character sting indicating the type for this attribute. The values for this property can be as follows:
D – Date
N – Number
S – String
This property is read-write.
This section provides an overview of the SearchCategory class and discusses:
SearchCategory class methods.
SearchCategory class properties.
SearchCategory is the PeopleCode representation of a search category definition, which groups search data source definitions. A search category is a searchable collection of indexes. SearchCategory objects can only be constructed by giving the name of a search category definition that has already been saved to the database. In general SearchCategory objects are instantiated either to be assigned to the Categories property of a SearchQuery object or to be passed to methods of the SearchAdminService.
In this section, the SearchCategory class methods are presented in alphabetical order.
Syntax
GetAllAttributes()
Description
Use this method to return the union of all the attributes available across all the search definitions assigned to this search category.
Parameters
None.
Returns
An array of SearchAttribute objects.
See Also
Syntax
GetConfiguredFilterAttributes()
Description
Use this method to return a list of advanced search filter attributes defined and configured for the advanced search for this search category. These are the attributes that have been configured on the Advanced Search Fields page.
Parameters
None.
Returns
An array of SearchAttribute objects.
See Also
Syntax
GetFacetFilters()
Description
Use this method to return an array of facet filters for a specific search category. Dynamically building this array based on system metadata avoids the hard-coding of facet names in your PeopleCode programs. However, this means that this method can only be used for search categories defined on the local system (therefore, it cannot be used for universal search).
Parameters
None.
Returns
An array of FacetFilter objects.
See Also
Syntax
GetLastIndexedDateTime()
Description
Use this method to return a DateTime value representing the oldest index that is current from all the indexed search definitions in this category. If no search definition in this category has ever been indexed, this method returns Null.
Parameters
None.
Returns
A DateTime value.
Syntax
GetNonConfiguredFilterAttributes()
Description
Use this method to return a list of advanced search filter attributes defined but not configured for the advanced search for this search category. These are the attributes that have been defined for the search category but not configured on the Advanced Search Fields page.
Parameters
None.
Returns
An array of SearchAttribute objects.
See Also
Syntax
GetRequestedAttributes()
Description
Use this method to return the list of search attributes that have been configured as display-only attributes on the Display Fields page. Since this method returns the display label for these search attributes, you must also use the GetRequestedFields method to return the list of search fields to pass to the query API.
Parameters
None.
Returns
An array of SearchAttribute objects.
See Also
Syntax
GetRequestedFields()
Description
Use this method to return the list of search fields that have been configured as display-only attributes on the Display Fields page. This array can then be passed to the RequestedFields method of the SearchQuery class. Since this method returns the query field names for the search attributes, you must also use the GetRequestedAttributes method to return the display labels to display in the user interface.
Parameters
None.
Returns
An array of SearchField objects.
Example
PT_SEARCH:SearchCategory &cat = create PT_SEARCH:SearchCategory("MY_SRCH_CAT"); &qry.Categories = CreateArray(&cat); &qry.RequestedFields = &cat.GetRequestedFields();
See Also
Syntax
SearchCategory(Name)
Description
Use this constructor to instantiate a SearchCategory object populated with the data from the specified saved definition.
Parameters
Name |
The name of the search category to instantiate as a string. |
Returns
A SearchCategory object.
Example
import PT_SEARCH:SearchCategory; Local PT_SEARCH:SearchCategory &SrchCat = create PT_SEARCH:SearchCategory⇒ ("MySrchCat");
See Also
In this section, the SearchCategory class properties are presented in alphabetical order.
Description
Use this property to return an array of string containing the names of the search definitions that have been assigned to this search category.
This property is effectively read-only.
Note. While this property is actually read-write, from PeopleCode, it is meant to be used in a read-only manner.
Description
Use this property to return the long description (display) for the search category as a string.
This property is effectively read-only.
Note. While this property is actually read-write, from PeopleCode, it is meant to be used in a read-only manner.
Description
Use this property to return a Boolean value indicating whether this search category has been deployed to a search provider.
This property is effectively read-only.
Note. While this property is actually read-write, from PeopleCode, it is meant to be used in a read-only manner.
Description
Use this property to return the name of this SearchCategory object as a string.
This property is effectively read-only.
Note. While this property is actually read-write, from PeopleCode, it is meant to be used in a read-only manner.
Description
Use this property to return a string representing the name of the search engine instance to which this search category has been deployed.
This property is effectively read-only.
Note. While this property is actually read-write, from PeopleCode, it is meant to be used in a read-only manner.
This section provides an overview of the SearchFactory class and discusses:
SearchFactory class methods.
SearchFactory class properties.
The SearchFactory class is a concrete factory class used to instantiate search engine-specific implementations of the SearchQueryService and other services.
In this section, the SearchFactory class methods are presented in alphabetical order.
Syntax
CreateQueryService(name)
Description
Use this method to instantiate a search engine-specific SearchQueryService object. This search engine-specific search query service enables accessing search engine-specific attributes of a SearchQuery object
Parameters
name |
Specifies the name of the search query service as a string. |
Returns
A SearchQueryService object.
Example
import PT_SEARCH:SearchFactory; import PT_SEARCH:SearchQueryService; Local PT_SEARCH:SearchFactory &MySearchFactory = create PT_SEARCH:SearchFactory(); Local PT_SEARCH:SearchQueryService &MySrchQrySvc = &MySearchFactory.⇒ CreateQueryService("default");
See Also
Syntax
SearchFactory()
Description
Use this constructor to instantiate a SearchFactory object, which allows you to instantiate a search-provider specific search query service.
Parameters
None.
Returns
A SearchFactory object.
Example
import PT_SEARCH:SearchFactory; Local PT_SEARCH:SearchFactory &MySearchFactory = create PT_SEARCH:SearchFactory();
In this section, the SearchFactory class properties are presented in alphabetical order.
Description
This property returns the name of the default search engine service as a string.
This property is read-only.
This section provides an overview of the SearchField class and discusses: .
SearchField class methods.
SearchField class properties.
The SearchField class is a superclass that requires implementation of a search engine-specific subclass. A SearchField is returned by the First, Item, ItemByName, and Next methods of the SearchFieldCollection class.
See Also
In this section, the SearchField class methods are presented in alphabetical order.
Syntax
getAsDate()
Description
Use this method to return the Value property as a Date value.
Note. This is an abstract method.
Parameters
None.
Returns
A Date value.
See Also
Syntax
getAsDateTime()
Description
Use this method to return the Value property as a DateTime value.
Note. This is an abstract method.
Parameters
None.
Returns
A DateTime value.
See Also
Syntax
getAsInteger()
Description
Use this method to return the Value property as a Integer value.
Note. This is an abstract method.
Parameters
None.
Returns
An Integer value.
See Also
Syntax
getAsNumber()
Description
Use this method to return the Value property as a Number value.
Note. This is an abstract method.
Parameters
None.
Returns
A Number value.
See Also
In this section, the SearchField class properties are presented in alphabetical order.
Description
This property returns the name of the search field as a string.
This property is read-only.
See Also
Description
This property returns the data type of the search field as a one-character string as follows:
D – Date
N – Number
S – String
This property is read-only.
Description
This property returns the value of the search field as a string. The Value property can be transformed from a String value to a Date, DateTime, Integer, or Number value using the methods of the SearchField class.
This property is read-only.
See Also
getAsDate, getAsDateTime, getAsInteger, getAsNumber.
This section provides an overview of the SearchFieldCollection class and discusses: SearchFieldCollection class methods.
The SearchFieldCollection class provides a collection of SearchField objects. Because the SearchFieldCollection class is a generic interface class, a search engine-specific subclass is required. A SearchFieldCollection is returned by the GetCustomAttributes method of the SearchResult class.
See Also
In this section, the SearchFieldCollection class methods are presented in alphabetical order.
Syntax
Count()
Description
Use this method to return the number of SearchField objects in the SearchField collection as an integer.
Parameters
None.
Returns
An integer.
Syntax
First()
Description
Use this method to return the first SearchField object in the SearchField collection. If the SearchField collection is empty, this method returns Null.
Parameters
None.
Returns
A SearchField object if successful, Null otherwise.
See Also
Syntax
Item(index)
Description
Use this method to return the SearchField object at the position in the SearchField collection specified by the index parameter.
Parameters
index |
Specifies the position of the SearchField object in the SearchField collection as an integer. |
Returns
A SearchField object if successful, Null otherwise.
See Also
Syntax
ItemByName(name)
Description
Use this method to return the SearchField object specified by the name parameter.
Note. The ItemByName method does not set the index for the SearchField object returned. Therefore, the Next method cannot be used after a call to ItemByName.
Parameters
name |
Specifies the name of the SearchField object as a string. |
Returns
A SearchField object if successful, Null otherwise.
See Also
Syntax
Next()
Description
Use this method to return the next SearchField object in the SearchField collection. This method can only be invoked after a successful invocation of the First, Item, or Next methods.
Note. The ItemByName method does not set the index for the SearchField object returned. Therefore, the Next method cannot be used after a call to ItemByName.
Parameters
None.
Returns
A SearchField object if successful, Null otherwise.
See Also
This section provides an overview of the SearchFilter class and discusses:
SearchFilter class properties.
SearchFilter class methods.
The SearchFilter class creates a filter for search results (similar to building a WHERE clause in a SQL statement) that is passed to the SearchQuery class.
In this section, the SearchFilter class methods are presented in alphabetical order.
Syntax
setDateFilter(date)
Description
Use this method to set a Date value as the search filter.
Parameters
date |
Specifies the search filter value as a Date value. |
Returns
None.
Example
import PT_SEARCH:SearchFilter; Local PT_SEARCH:SearchFilter &Srchflter; Local date &Date = DateValue("10/09/11"); &Srchflter.setDateFilter(&Date);
See Also
Syntax
setDateTimeFilter(datetime)
Description
Use this method to set a DateTime value as the search filter.
Parameters
datetime |
Specifies the search filter value as a DateTime value. |
Returns
None.
Example
import PT_SEARCH:SearchFilter; Local PT_SEARCH:SearchFilter &Srchflter; Local datetime &Date_TIME = DateTimeValue("10/13/97 10:34:25 PM"); &Srchflter.setDateTimeFilter(&Date_TIME);
See Also
In this section, the SearchFilter class properties are presented in alphabetical order.
Description
Use this property to set or return a SearchField object.
This property is read-write.
See Also
Description
Use this property to set or return the operator for the filter as a string. Depending on the type of the search attribute, the following operators can be used:
Operator |
String |
Number |
Date |
equals |
X |
X |
X |
notequals* |
X |
X |
X |
contains |
X |
||
greaterthan |
X |
X |
|
greaterthanequals |
X |
X |
|
lessthan |
X |
X |
|
lessthanequals |
X |
X |
* The notequals operator can be used when EnableExtendedFilterOperators property is set to true.
This property is read-write.
See Also
Description
Use this property to set or return the value for the filter as a string.
This property is read-write.
Use this property only when setting a string or a number (represented as a string) as a filter. If you wish to set a Date or a DateTime value as a filter, use the setDateFilter and setDateTimeFilter methods, respectively
See Also
This section provides an overview of the SearchQuery class and discusses:
SearchQuery class methods.
SearchQuery class properties.
The SearchQuery object is used to define the attributes of a search query—such as its category or categories (index or indexes), facet filters, query text, and so on—and then execute that query on a search engine instance. The required properties of a SearchQuery must be initialized before invoking the Execute method. However, which properties are required depend on the specific search engine. Moreover, all properties are not necessarily used for every execution of a search query. For example, if no filters are to be applied to the search then it is not necessary to initialize the Filter property.
A SearchQuery object is returned by the CreateQuery method of the SearchQueryService class.
See Also
In this section, the SearchQuery class methods are presented in alphabetical order.
Syntax
BrowseFacetNodes()
Description
Use this method to return an array of facet nodes with out actually executing a search. Because this method does not execute the search query, it is lot faster than the Execute method. This method relies on the Language property only and ignores other SearchQuery class properties and settings, such as facet filters.
Note. This is an abstract method.
Parameters
None.
Returns
An array of FacetNode objects.
See Also
Syntax
Execute(start, size)
Description
Use this method to execute the search query on the search engine. The Execute method returns search results beginning at the document number specified by start, and returns a maximum number of results specified by size.
The Execute method uses the following SearchQuery class properties:
Categories
Note. If this property is undefined, the query will be executed against all search categories.
Language
Note. If no value is specified, the query will be executed against all languages.
QueryText
Note. If no value is specified, then all documents in the index are returned.
Note. This is an abstract method.
Parameters
start |
Specifies an integer representing the first document of the returned results. This parameter must be greater than or equal to 1. If start exceeds the total number of documents in the index or the search engine-specified maximum number of results, then zero results are returned. |
size |
Specifies the maximum size of the result set as an integer. This parameter should be greater than or equal to 1. If size is set to 0, then 10 documents are returned. |
Returns
A SearchResultCollection object.
Example
import PT_SEARCH:SearchFactory; import PT_SEARCH:SearchQueryService; import PT_SEARCH:SearchQuery; import PT_SEARCH:SearchResultCollection; /* Instantiate the SearchQuery object */ Local PT_SEARCH:SearchFactory &factory = create PT_SEARCH:SearchFactory(); Local PT_SEARCH:SearchQueryService &svc = &factory.CreateQueryService("default"); Local PT_SEARCH:SearchQuery &srchQuery = &svc.CreateQuery(); /* Initialize the search query */ &srchQuery.QueryText = "some text"; &srchQuery.Language = &lang_cd; &srchQuery.MarkDuplicates = False; &srchQuery.RemoveDuplicates = False; /* Execute the search query */ Local number &start = 1; Local number &size = 10; Local PT_SEARCH:SearchResultCollection &results = &srchQuery.Execute(&start,⇒ &size); /* Re-execute the search query to return the next 10 results */ &start = &start + &size; &results = &srchQuery.Execute(&start, &size);
See Also
Categories, Language, QueryText.
Syntax
FormatDateFilter(datefilter)
Description
Use this method to convert dates from the internal PeopleSoft date format into a search engine-specific format. You must use this method when the query string is programmatically created.
Note. This is an abstract method.
Parameters
datefilter |
Specifies the search filter as a Date value. |
Returns
A String value.
See Also
Syntax
FormatDateTimeFilter(datetmfilter)
Description
Use this method to convert dates from the internal PeopleSoft date/time format into a search engine-specific format. You must use this method when the query string is programmatically created.
Note. This is an abstract method.
Parameters
datetmfilter |
Specifies the search filter as a DateTime value. |
Returns
A String value.
See Also
In this section, the SearchQuery class properties are presented in alphabetical order.
Description
Use this property to set or return the list of search categories (search indexes) you want to search as an array of SearchCategory objects. If this property is defined, the Execute method will run the query on all the search categories specified in this property.
Important! If this property is undefined, the query will be executed against all search categories in the search engine instance.
This property is read-write.
Example
The following example uses two search categories called cat1 and cat2.
import PT_SEARCH:SearchCategory; Local array of PT_SEARCH:SearchCategory &cats; &cats = CreateArray(create PT_SEARCH:SearchCategory("cat1")); &cats.Push(create PT_SEARCH:SearchCategory("cat2")); &searchQuery.Categories = &cats;
See Also
Description
Use this property to set a search string that contains one or more words. The search results include those documents that contain any of these words and whatever is defined by other search text properties (for example, ContainsExactPhrase, QueryText, or WithoutWords).
This property is not required.
This property is read-write.
Description
Use this property to set a search string that contains one or more words. The search results include those documents that this exact phrase and whatever is defined by other search text properties (for example, ContainsAnyWords, QueryText, or WithoutWords).
This property is not required.
This property is read-write.
Description
This property is reserved for future use.
Description
Use this property to set or return the size of the result set as an integer. After invoking the Execute method, use this property to return the value of the size parameter passed to Execute. Alternatively, if the search query is to be executed by the ExecuteQuery method of the QueryService class, then use this property to specify the size of the result set.
Example
For example, one could compare DocsRequested to the GetDocumentCount method of the ResultCollection class to determine if there are possibly more documents to be retrieved.
The StartIndex and DocsRequested properties (that is, the start and size parameters to the Execute method) allow for “chunking” of search results. The idea is to repeatedly call Execute while increasing the start parameter by the increment specified by size. For example, the following psuedo-code will return the first 100 results the first time through the loop. The second time through the loop, it will return documents 101 through 200, and so on.
int start=1, size=100 ,.// return results in chunks of 100 documents while not done results = query.execute(start, size) if (results.GetDocumentCount() < query.DocsRequested) done = true // we got fewer documents than we asked for so we're done executing this ⇒ // query if (results.GetDocumentCount() = 0) done = true // no more documents being returned so we're done executing this query // do something with the results start = start + size end-while
See Also
Description
Use this property to set or return a Boolean value indicating whether to enable the set of extended filter operators (specifically, the notequals operator). In addition, when this property is set to True, all search filters are added to the QuerytText property and sent to the search engine in this manner. Otherwise, when this property is set to False, the search filters are handled by the Filters property as an array of SearchFilter objects. The default value is False.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return an array of FacetFilter objects on which the search results are currently filtered.
Note. The SearchCategory class GetFacetFilters method can be used to get the initial list of facet filters.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return a search filter connector as a string. A search filter connector is used to join search filters. The acceptable values are: AND and OR. The default value is AND.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return the list of search filters as an array of SearchFilter objects.
This property is not required.
This property is read-write.
See Also
Description
This property is reserved for future use.
Description
Use this property to set or return a three-character string representing the language code to which the search query results should be restricted. This property must be a PeopleSoft language code—for example, ENG for English, FRA for French, and so on.
Note. If no value is specified, the query will be executed against all languages.
This property is read-write.
Example
&SearchQuery.Language = "ENG";
See Also
Selecting Database Character Sets
Description
Use this property to set or return a Boolean value indicating whether duplicates in the result set should be marked as such. A search result can be identified by running the isDuplicate method.
This property is not required. However, it defaults to False if no value is specified.
This property is read-write.
See Also
Description
Use this property to set or return an Integer value representing the maximum number of child facet nodes. For example, if there are 100 facet values, setting this property to 10 will return the first ten facet values as determined by the sorting order. If this property is not set, the default value is -1, which indicates to return all child nodes.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return an Integer value representing the minimum number of documents required for the child facet node to be returned. Child facet nodes with less than this document count are not returned. If this property is not set, the default value is 1, which indicates that a facet node must have at least one document to be returned.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return the programmatically generated search string as a string. This search string is not displayed to the end user.
This property is not required.
This property is read-write.
Description
Use this property to set or return a string representing the text to use in the search query. The search results include those documents that contain this text and whatever is defined by other search text properties (for example, ContainsAnyWords, ContainsExactPhrase, or WithoutWords).
Note. If no value is specified and none of the other search text properties are defined, then all documents in the index are returned.
This property is read-write.
Description
Use this property to set or return a Boolean value indicating whether duplicates should be removed from the result set.
This property is not required. However, it defaults to False if no value is specified.
This property is read-write.
See Also
Description
Use this property to set or return the list of custom attributes to be included for each search result. The list is an array of SearchField objects.
This property is not required.
This property is read-write.
See Also
Description
Use this property to set or return a Boolean value indicating whether to compute and return document counts per facet node.
This property is not required. However, it defaults to True if no value is specified.
This property is read-write.
See Also
Description
Use this property to set or return a string of search terms as a string. This is used to search within the current results.
This property is not required.
This property is read-write.
Description
Use this property to set or return a String value indicating the sort order by which facet nodes are sorted:
Value |
Description |
ALPHA_ASC |
Sort by node name alphabetically ascending. |
ALPHA_DES |
Sort by node name alphabetically descending. |
COUNT_ASC |
Sort by document count numerically ascending. |
COUNT_DES |
Sort by document count numerically descending. COUNT_DES is the default value, which means that facet nodes with highest document count are displayed first in the list. |
This property is not required.
This property is read-write.
See Also
Description
This property is reserved for future use.
Description
Use this property to set or return an integer representing the first document of the result set. After invoking the Execute method, use this property to return the value of the start parameter passed to Execute. Alternatively, if the search query is to be executed by the ExecuteQuery method of the QueryService class, then use this property to specify the first document of the result set.
See Also
Description
This is reserved for future use.
Description
Use this property to set a search string that contains one or more words. The search results include those documents that do not include any of these words and whatever is defined by other search text properties (for example, ContainsAnyWords, ContainsExactPhrase, or QueryText).
This property is not required.
This property is read-write.
This section provides an overview of the SearchQueryService class and discusses: SearchQueryService class methods.
The SearchQueryService provides the ability to instantiate a SearchQuery object along with other interfaces. Because the SearchQueryService class is an interface class, it requires a search engine-specific search query service and search query class to instantiate a search engine-specific SearchQuery object.
A SearchQueryService object is created by the CreateQueryService method of the SearchFactory class.
See Also
In this section, the SearchQueryService class methods are presented in alphabetical order.
Syntax
CreateQuery()
Description
Use this method to instantiate a SearchQuery object.
Note. This is an abstract method.
Parameters
None.
Returns
A SearchQuery object.
See Also
Syntax
ExecuteQuery(&query)
Description
Use this method to execute the specified search query on the search provider and return the collection of search results. This method is equivalent to invoking the Execute method of the SearchQuery class.
Note. This is an abstract method.
Parameters
&query |
Specifies the search query as a SearchQuery object. |
Returns
A SearchResultCollection object.
See Also
This section provides an overview of the SearchResult class and discusses: SearchResult class methods
The SearchResult object represents a specific search result (that is, a document) in a SearchResultCollection object. Because the SearchResult class is a generic interface class, a search engine-specific subclass is required. The SearchResult object is defined to comprise 10 standard attributes (or “properties”)—for example, title, URL, summary, and so on. These private, read-only “properties” can be accessed only through the methods of the SearchResult class.
A SearchResult object is instantiated by the First, Item or Next methods of the SearchResultCollection.
See Also
In this section, the SearchResult class methods are presented in alphabetical order.
Syntax
GetCategoryNames()
Description
Use this method to return the list of search categories to which this search result belongs as an array of string.
Parameters
None.
Returns
An array of string.
See Also
Syntax
GetContentLength()
Description
Use this method to return the content length for this search result as an integer. If the content length cannot be determined, this method returns -1.
The content length, signature, title, and other attributes are used to determine whether a search result is a duplicate.
Parameters
None.
Returns
An integer.
See Also
Syntax
GetCustomAttributes()
Description
Use this method to return a SearchFieldCollection representing the custom attributes for this search result. A SearchFieldCollection is a collection of SearchField objects.
Parameters
None.
Returns
A SearchFieldCollection object.
See Also
Syntax
GetLanguage()
Description
Use this method to return a string representing the three-character PeopleSoft language code for this search result.
Parameters
None.
Returns
A string.
See Also
Syntax
GetLastModified()
Description
Use this method to return the last modified date and time for this search result.
Parameters
None.
Returns
A DateTime value.
Syntax
GetScore()
Description
Use this method to return the search engine-specific score for this search result as an integer.
Parameters
None.
Returns
An integer.
Syntax
GetSignature()
Description
Use this method to return the search engine-computed signature for this search result as an integer. If the signature cannot be determined, this method returns -1.
The signature, content length, title, and other attributes are used to determine whether a search result is a duplicate.
Parameters
None.
Returns
An integer.
See Also
Syntax
GetSummary()
Description
Use this method to return the summary for this search result as a string.
Parameters
None.
Returns
A string.
Syntax
GetTitle()
Description
Use this method to return the title for this search result as a string.
Parameters
None.
Returns
A string.
Syntax
GetUrlLink()
Description
Use this method to return the URL for this search result as a string.
Parameters
None.
Returns
A string.
Syntax
HasDuplicate()
Description
Use this method to return a Boolean value indicating whether this search result has duplicates.
Parameters
None.
Returns
A Boolean value: True if the search result has duplicates, False otherwise.
See Also
Syntax
IsDuplicate()
Description
Use this method to return a Boolean value indicating whether this search result is a duplicate. Exact duplicates and near duplicates are both marked as duplicates by the PeopleSoft Search Framework.
An exact duplicate is a document that satisfies all of the following conditions exactly:
Same signature
Same content length
Same title
A near duplicate (a similar document) is a document that satisfies any of the following conditions:
Same signature and documents are not empty.
Same (non-null) title and same 4K checksum.
Same (non-null) title and URLs differ by not more than one element (an element is a folder name and doesn't include the HTML/JSP page name of the HTTP GET parameters).
Parameters
None.
Returns
A Boolean value: True if this search result is a duplicate, False otherwise.
See Also
GetContentLength, GetSignature, GetTitle, GetUrlLink, HasDuplicate.
This section provides an overview of the SearchResultCollection class and discusses: SearchResultCollection class methods.
The SearchResultCollection class provides a collection of SearchResult objects. Because the SearchResultCollection class is a generic interface class, a search engine-specific subclass is required. A SearchResultCollection object is returned by the Execute method of the SearchQuery class.
See Also
In this section, the SearchResultCollection class methods are presented in alphabetical order.
Syntax
First()
Description
Use this method to return the first SearchResult object in the SearchResult collection. If the SearchResult collection is empty, it returns Null.
Parameters
None.
Returns
A SearchResult object if successful, Null otherwise.
See Also
Syntax
GetDocumentCount()
Description
Use this method to return the actual number of SearchResult objects (documents) in the SearchResult collection.
Note. This is an abstract method.
Parameters
None.
Returns
An integer.
See Also
Syntax
GetDuplicatesMarked()
Description
Use this method to return a Boolean value indicating whether duplicate items in the collection are marked as duplicates—that is, whether the search query was executed with MarkDuplicates set to true.
Note. This is an abstract method.
Parameters
None.
Returns
A Boolean value: True if duplicates were marked, False otherwise.
See Also
Syntax
GetDuplicatesRemoved()
Description
Use this method to return a Boolean value indicating whether duplicate items in the collection were removed—that is, whether the search query was executed with RemoveDuplicates set to true.
Note. This is an abstract method.
Parameters
None.
Returns
A Boolean value: True if duplicates were removed, False otherwise.
See Also
RemoveDuplicates, IsDuplicate.
Syntax
GetEstimatedHitCount()
Description
Use this method to return the estimated hit count for the search query as an integer. The estimated hit count can be used as a device for fetching search results on demand rather than retrieving all of the search results initially.
Note. This is an abstract method.
Parameters
None.
Returns
An integer.
Syntax
GetFacetNodes()
Description
Use this method to return an array of facet nodes available for this search result collection.
Parameters
None.
Returns
An array of FacetNode objects if successful, Null otherwise.
See Also
Syntax
GetQueryObject()
Description
Use this method to return the SearchQuery object that was used for the search.
Parameters
None.
Returns
A SearchQuery object.
See Also
Syntax
GetQueryText()
Description
Use this method to return the search text that was used for the search query as a string.
Note. This is an abstract method.
Parameters
None.
Returns
A string.
See Also
Syntax
GetStartIndex()
Description
Use this method to return the value of the &start parameter that was used to execute this search query.
Note. This is an abstract method.
Parameters
None.
Returns
An integer.
See Also
Syntax
Item(index)
Description
Use this method to return the SearchResult object at the position in the SearchResult collection specified by the index parameter.
Parameters
index |
Specifies the position of the SearchResult object in the SearchResult collection as an integer. |
Returns
A SearchResult object if successful, Null otherwise.
See Also
Syntax
Next()
Description
Use this method to return the next SearchResult object in the SearchResult collection. This method can only be invoked after a successful invocation of the First, Item, or Next methods.
Parameters
None.
Returns
A SearchResult object if successful, Null otherwise.
See Also
This section provides an overview of the SearchAuthnQueryFilter class and discusses: SearchAuthnQueryFilter class methods.
The SearchAuthnQueryFilter class provides an abstract method to evaluate a list of values for a security attribute for a given search user. An application that requires document-level security in a searchable object must implement and extend the evaluateAttrValues abstract method.
In this section, the SearchAuthnQueryFilter class methods are presented in alphabetical order.
Syntax
evaluateAttrValues(SBO_name, attr, user_ID)
Description
Use this method to return a list of values for a security attribute for a search user.
Note. This is an abstract method.
Parameters
SBO_name |
Specifies a string representing a searchable object upon which the security attribute value needs to be evaluated |
attr |
Specifies a string representing the security attribute value as a document-level filtering attribute. |
user_ID |
Specifies user ID that executed the search query as a string. |
Returns
An array of string.
Example
import PTSF_SECURITY:*; class UserPermission implements PTSF_SECURITY:SearchAuthnQueryFilter method UserPermissionList(); method evaluateAttrValues(&sboName As string, &secAttr As string, &searchUser⇒ As string) Returns array of string; end-class; method UserPermissionList end-method; method evaluateAttrValues /+ &sboName as String, +/ /+ &secAttr as String, +/ /+ &searchUser as String +/ /+ Returns Array of String +/ /+ Extends/implements PTSF_SECURITY:SearchAuthnQueryFilter.evaluateAttrValues +/ Local SQL &userPermissions_SQL; Local array of string &retvalues; Local string &isAdmin; &retvalues = CreateArrayRept("", 0); SQLExec("SELECT 'X' FROM PSROLEUSER WHERE ROLEUSER=:1 AND (ROLENAME=:2 OR⇒ ROLENAME=:3)", &searchUser, "Portal Administrator", "PeopleSoft Administrator",⇒ &isAdmin); If All(&isAdmin) Then &retvalues = CreateArray("R:Admin"); Else &retvalues.Push("0"); /* Public */ &retvalues.Push("1:" | &searchUser); /* Author */ &userPermissions_SQL = CreateSQL("SELECT DISTINCT A.CLASSID FROM PSROLECLASS⇒ A, PSROLEUSER B, PSOPRDEFN C WHERE A.ROLENAME = B.ROLENAME AND C.OPRID =⇒ B.ROLEUSER AND C.OPRID = :1", &searchUser); Local string &classids; While &userPermissions_SQL.Fetch(&classids) &retvalues.Push(&classids); End-While; End-If; Return &retvalues; end-method;
This section provides additional code examples for the PeopleSoft Search Framework:
Searching using facets.
The following provides an example of searching using facets.
import PT_SEARCH:*; /* The following 3 lines are same for any implementation */ Local PT_SEARCH:SearchFactory &factory = create PT_SEARCH:SearchFactory(); Local PT_SEARCH:SearchQueryService &svc = &factory.CreateQueryService("default"); Local PT_SEARCH:SearchQuery &qry = &svc.CreateQuery(); /* This is the keywords user is searching for; */ &qry.QueryText = "a"; /* &qry.StartIndex , For the first request this is always 1 When using pagination to get the next set of results this can be changed to ⇒ DocsRequested + StartIndex ex: here 51 on next request is 101.. The maximum number of results that can come back is 200 which is configurable ⇒ at SES the max results for this query can be fetched from SearchResultCollection ⇒ hit count */ &qry.StartIndex = 1; /* &qry.DocsRequested , Number of results to be returned by the search , It is ⇒ recommended to keep this default to 50 for performance reasons and show 10 ⇒ results per page and if the end user is requesting for 6th page request with ⇒ start index to 51; */ &qry.DocsRequested = 50; /* &qry.RemoveDuplicates ,&qry.MarkDuplicates Currently these two should always be ⇒ set to false as our we generate unique id for every search document. &qry.RemoveDuplicates = False; */ &qry.MarkDuplicates = False; /* This should be set to empty value to search in documents from all languages . &qry.Language This can be provided a value to search in language specific documents Currently the frame work does not allow searching in selected languages , its ⇒ either all or one language */ &qry.Language = %Language_User; /* &qry.Categories , Array of categories on which the search can be performed on If not specified we will search in all categories */ Local PT_SEARCH:SearchCategory &srchCat = create PT_SEARCH:SearchCategory("MY_SRCH_⇒ CAT"); &qry.Categories = CreateArray(&srchCat); /* &qry.RequestedFields , Array of custom attribute values in the search result Optional , if not specified all the standard information like URL , body , title ⇒ are still returned */ &qry.RequestedFields = &srchCat.GetRequestedFields(); /* &qry.FacetFilters , Array of facets filter the search result by Optional , If not specified No facets will be returned Limitation : Only documents having this facet and path (If included) will be ⇒ returned in the search result. FacetFilter constructor will take two arguments 1.Facet name , 2.Facet Path FacetFilter is required when dealing with hierarchy facets Ex: Attribute LOCATION ⇒ has COUNTRY/STATE/CITY To filter results for country USA the request will be FacetName: LOCATION , Facet ⇒ Filter: USA To filter results for country USA and State CA the request will be FacetName: ⇒ LOCATION , FacetFilter: USA/CA &qry.FacetFilters = CreateArray(create PT_SEARCH:FacetFilter("SETID", "")); &qry.FacetFilters.Push(create PT_SEARCH:FacetFilter("STATE", "")); */ &qry.FacetFilters = &srchCat.GetFacetFilters(); /* The other optional facet request related query parameters that can be set when ⇒ searching for facets ReturnFacetValueCounts -- returns the counts only if this is set to true , ⇒ default is true , set this to false if we do not want to display counts. MinmumDocumentsPerFacetValue -- only return facet value whose document hit count ⇒ is more that this , ex: only facets values which have hit count more than 5 or 1; MaximumNumberOfFacetValues -- the children facets can be huge list , this can ⇒ limit the return list SortFacetValuesBy -- ALPHA_DES , ALPHA_ASC , COUNT_DES , COUNT_ASC the max fetch returns the only top few children this can be used to provide ⇒ which top children to return */ /* Execute the query and get back the results */ Local PT_SEARCH:SearchResultCollection &res = &qry.Execute(&qry.StartIndex, ⇒ &qry.DocsRequested); /* Find the number of results returned by the search , this will always be less than ⇒ or equal to "&qry.DocsRequested" */ Local integer &resultSize = &res.GetDocumentCount(); /* Find the number of potential results that can be returned; This can be used to determine if we get the next set of results and how many ⇒ pages that can be shown to the user */ Local integer &estmatedResultCount = &res.GetEstimatedHitCount(); Local string &outHtml; /* FacetNode will have the facet values and the hit count for the results GetFacetNodes will return array of the facet nodes in the result */ Local array of PT_SEARCH:FacetNode &facetNodes = &res.GetFacetNodes(); /* Facet Node has various information which can be retrieved. &facetNodes [&i].DocumentCount will return hit count &facetNodes [&j].FacetValue , is the facet value before translation &facetNodes [&i].DisplayValue , translated facet value (currently this is not yet ⇒ supported by SES) &facetNodes [&i].Path , to which the facet value belongs to &facetNodes [&i].getChildNodes() will return child facet nodes and will have all ⇒ above properties */ /* loop through facet nodes and there children and render it in the UI */ If &facetNodes <> Null And &facetNodes.Len <> 0 Then &outHtml = &outHtml | "<table border='1'><tr><th>Name</th><th>Value⇒ </th><th>DisplayValue</th><th>DocCount</th><th>Path</th><th></th></tr>"; For &i = 1 To &facetNodes.Len &outHtml = &outHtml | "<tr><td>" | &facetNodes [&i].FacetName | "</td>⇒ <td>" | &facetNodes [&i].FacetValue | "</td><td>"; &outHtml = &outHtml | &facetNodes [&i].DisplayValue | "</td><td>"; &outHtml = &outHtml | &facetNodes [&i].DocumentCount | "</td><td>" | ⇒ &facetNodes [&i].Path | "</td></tr>"; If &facetNodes [&i].HasChildren Then &outHtml = &outHtml | "<tr><th>Child</th><th>Name</th><th>Value⇒ </th><th>DisplayValue</th><th>DocCount</th><th>Path</th></tr>"; Local array of PT_SEARCH:FacetNode &childFacetNodes = &facetNodes ⇒ [&i].getChildNodes(); For &j = 1 To &childFacetNodes.Len &outHtml = &outHtml | "<tr><td></td><td>" | &childFacetNodes ⇒ [&j].FacetName | "</td><td>" | &childFacetNodes [&j].FacetValue; &outHtml = &outHtml | "</td><td>" | &childFacetNodes [&j].DisplayValue; &outHtml = &outHtml | "</td><td>" | &childFacetNodes [&j].⇒ DocumentCount | "</td><td>" | &childFacetNodes [&j].Path | "</td></tr>"; End-For; End-If; End-For; &outHtml = &outHtml | "</table>"; Else &outHtml = &outHtml | "<br><bold>No Facet Nodes</bold>"; End-If; /* &res.Item(&i) returns a PT_SEARCH:SearchResult for each search result document ⇒ which has various information which can be retrieved for display purposes &srchResult.GetUrlLink , returns the URL which can take the user to the ⇒ transaction page &srchResult.GetTitle , returns the Title for the search result document &srchResult.GetSummary , returns the body for the search result document &srchResult.GetScore , returns the score for the search result document &srchResult.GetCategoryNames , returns the search categories this search result ⇒ document belongs too &srchResult.GetCustomAttributes , will return a SearchFieldCollection which has ⇒ custom search attribute values */ /* loop through each result and render it in the UI */ Local PT_SEARCH:SearchResult &srchResult; For &i = 1 To &resultSize &srchResult = &res.Item(&i); &outHtml = &outHtml | "<font size=""2""><hr/>Title: <a href="" " | ⇒ &srchResult.GetUrlLink() | """>" | &srchResult.GetTitle() | "</a>"; rem &outHtml= &outHtml| ""; &outHtml = &outHtml | "<br>Summary: " | &srchResult.GetSummary(); &outHtml = &outHtml | "<br>Score: " | &srchResult.GetScore(); &outHtml = &outHtml | " Source Group: "; If Not &srchResult.GetCategoryNames() = Null Then For &j = 1 To &srchResult.GetCategoryNames().Len &outHtml = &outHtml | " " | &srchResult.GetCategoryNames()[&j]; End-For; End-If; &outHtml = &outHtml | "<font size=""2"" color=#009933><br>Url: " | ⇒ &srchResult.GetUrlLink() | "</font>"; &outHtml = &outHtml | "<font size=""2"" color=#097054><br>Signature: " | ⇒ &srchResult.GetSignature() | "</font>"; &outHtml = &outHtml | "<font size=""2"" color=#097054> / Content Length: " ⇒ | &srchResult.GetContentLength() | "</font>"; &outHtml = &outHtml | "<font size=""2"" color=#097054> / Language: " | ⇒ &srchResult.GetLanguage() | "</font>"; &outHtml = &outHtml | "<font size=""2"" color=#000000><br>Last Modified: " ⇒ | &srchResult.GetLastModified() | "</font>"; Local PT_SEARCH:SearchFieldCollection &customs = &srchResult.⇒ GetCustomAttributes(); If (&customs <> Null) Then For &j = 1 To &customs.Count() &outHtml = &outHtml | "<br>" | &customs.Item(&j).Name | "=" | ⇒ &customs.Item(&j).Value; End-For; End-If; &outHtml = &outHtml | "</font>"; End-For; &outHtml = &outHtml | "</BODY></HTML>";