This chapter provides an overview of Search classes and discusses the following topics:
Search class hierarchy
Error handling
Search object declaration
Scope of the search objects
Session class method
Search class reference section
See Also
Configuring Search and Building Search Indexes
The Search API enables you to create a logical search index as well as access a search index and query its contents. Every search index in the PeopleSoft system must have a logical search index created to describe it.
The SearchIndex objects can be created for the following types of content:
Indexing content references in a PeopleSoft portal
Indexing data in PeopleSoft records
Spidering a file system
Spidering URL's
User defined indexes (such as a PeopleSoft application)
Portal users can index and search on content references through the Search API using PeopleCode. The Portal Administration pages provide a GUI access to indexing a portal. This search index is what is used when doing searches on the portal. Users can create search indexes and index data in PeopleSoft records. The Search Index Designer provides a GUI tool to create these indexes.
Users can create search indexes and spider files systems or URL's. The Search Index Designer provides a GUI tool to create these indexes.
Users can create their own custom search indexes.
PeopleSoft has integrated the Verity search engine into PeopleTools.
All searches done using the Search API are executed against a Verity search index. A search index is similar to a record in many ways:
It has fields that hold information about a document.
It stores one row of information for each document indexed.
It can store information in different languages.
You must build a search index before you can use the Search API.
For the portal, you can build a search index either using the Search API (BuildSearchIndex) PortalRegistry method) or using the Portal Administration.
To index and search something that isn't registered in the portal, you must build your own search index.
After you've built a search index, you can execute a search against the index, and execute a search query. A search query (SearchQuery object) represents the items in an index that match a query. These matched items are retrieved in the SearchResult collection.
In addition, you can also check for any errors that were generated by the search.
If you specify multiple indexes to search over, and none of the collections' indexes are built, an error is returned. Otherwise, if there is at least one built index collection, and there is a matching search result, it is displayed.
See Also
You specify the size of the SearchResult collection when you execute the search. If more SearchResults were returned than can be contained in the single SearchResult collection, you can access the next set of SearchResults by executing the search again, specifying only a different starting point.
For example, suppose your search returns 28 documents that match the query, but the size you specified when you executed the search was 10. You have to execute the search three times to access all the documents that matched the query.
The following pseudo-code could be behind a "Next Matches" button.
&Start indicates at what document you want to start your search query.
&Size is the number of search results returned in every search.
&SearchQuery is the query object you created at the start of your program.
&Start = &Start + &Size; &SearchQuery.Execute(&Start, &Size);
Each SearchResult in the SearchResult collection contains:
Key
Score
SearchFields
The key uniquely identifies each document in the SearchResult collections. Keys provide a link back to the item that was indexed. The value returned by the Key property depends on the search index. If you're using a search index with the portal, the key contains the content provider and the URL. If you're not using the portal search index, the key is determined by the developer who created the search index.
Each query returns matched documents in relevance-ranked order, with those documents considered most relevant appearing at the top of the list. During search processing, a score is calculated for each retrieved document. This is the value stored in the Score property. A Score is assigned a value from 0.00 to 1.00, where 1.00 represents a perfect match to the search criteria provided.
Each SearchResult contains fields. If this is a non-portal search, these fields were specified by the developer when they created the search index. If this is a portal search, the fields are the following:
Field |
Description |
VALID_FROM_DATE |
Valid from date |
VALID_TO_DATE |
Valid to date |
CREATION_DATE |
Creation date |
CONTENT_PROVIDER |
Content provider name |
URL |
URL |
DESCRIPTION |
Description |
An external URL has the full URI attached so it might look like this:
URL: http://sports.mysports.com/nba/teams/chi/
Whereas a URL with a content provider specified is comprised of two portions.
Content Provider: HRMS URL:ICType=Panel&Menu=ADMINISTER_WORKFORCE_(U.S.)&Market=GBL&PanelGroupName=ABSENCE_HISTORY1
You can interrogate each field in the SearchField collection to find its name and value.
See Also
There are many different classes used with the Search API. The following flowchart shows the different classes, and how they are interrelated.
Search class hierarchy (part 1 of 2)
Search class hierarchy (part 2 of 2)
All errors for the Search API, like the other APIs, are logged in the PSMessages collection, instantiated from a session object.
The search classes log errors "interactively", that is, as they happen. For example, suppose you specified an invalid SearchField name. The error would be logged in the PSMessages collection as soon as you executed the ItemByName method.
If you want to search for errors in the query string before you execute the search, you can use the SearchQuery Parse method.
When to check for errors depends on your application. However, if you check for errors after every assignment, you may see a performance degradation.
The easiest way to check for errors is to check the number of messages in the PSMessages collection, using the Count property. If the Count is 0, there are no errors.
Local ApiObject &MySession; Local ApiObject &ERRORCOL; Component ApiObject &SearchQuery, &SearchResultCol, &SearchResult; Component Number &Start, &Size; &MySession = %Session; If &MySession Then /* connection is good */ &SearchQuery = &MySession.GetSearchQuery(); &SearchQuery.Indexes = "PSC"; &SearchQuery.Language = %Language; &SearchQuery.QueryText = SEARCH_RECORD.USER_QUESTION.Value; &Start = 1; &Size = 20; &SearchResultsCol = &SearchQuery.Execute(&Start, &Size); If &SearchResult.HitCount > 0 Then For &I = 1 to &SearchResultCol.Count &SearchResult = &SearchResultCol.Item(&I); /* Do processing */ /* Do error checking */ &ERRORCOL = &MySession.PSMessages; If (&ERRORCOL.Count <> 0) Then /* errors occurred . . . do processing */ Else /* no errors */ End-If; End-For; Else /* do processing for no returned matches to query */ End-if; Else /* do processing for no connection */ End-If;
See Also
All search objects, like a SearchResult collection, a SearchField, and so on, are declared as type ApiObject. For example,
Local ApiObject &SearchResultCol; Local ApiObject &SearchField;
Note. All Search objects can be declared only as Local.
A search object can be instantiated only from PeopleCode using a PortalRegistry or Session object.
This object can be used anywhere you have PeopleCode, that is, in an application class, Application Engine PeopleCode, record field PeopleCode, and so on. The limits placed on where you can use this object depend on how the object is used. For example, if you're doing search index administration, you are updating the database, and that can be done only in certain events.
Note. The Search API currently does not work in an Application Engine program run on the System 390.
A SearchQuery object must be instantiated from either a session object or a Portal Registry object. The Search API doesn't have any built-in functions.
In this section, we discuss the Session class methods. The methods are discussed in alphabetical order.
See Also
Session Class, PortalRegistry Classes.
Syntax
GetSearchIndexes()
Description
The GetSearchIndexes method returns a collection of SearchIndexes objects.
A SearchIndexes object and its children are used only for index administration, that is, creating and building search indexes. This method is not used with queries.
Parameters
None.
Returns
A SearchIndexes Collection object, populated with zero or more SearchIndex objects.
See Also
Syntax
GetSearchQuery()
Description
The GetSearchQuery method returns an empty search query object used to start a search.
Parameters
None.
Returns
An empty search query object.
Example
&SearchQuery = %Session.GetSearchQuery();
See Also
PortalRegistry class: GetSearchQuery method.
A SearchQuery object must be instantiated from either a session object or a Portal Registry object. The Search API doesn't have any built-in functions.
In this section, we discuss the PortalRegistry class methods. The methods are discussed in alphabetical order.
See Also
Syntax
BuildSearchIndex(Language)
Description
The BuildSearchIndex method builds a portal search index for the specified language.
Search Collection Path Considerations
The Search Collection Path field in the configuration file points to a directory where collections can be built and queried through the search API. However, the BuildSearchIndex method always builds the collection in the default path, that is, in the following:
<PS_HOME>\data\search\<portal_name>\<db_name>\<lang_cd>
Parameters
Language |
Specify the language code that you want the search index built in. |
Returns
An optional Boolean value: True if the search index is built successfully, False otherwise.
Syntax
GetSearchQuery()
Description
The GetSearchQuery method returns an empty search query object.
Note. When you use this method to get a search query, the index property is already set to the portal registry search index, and the language property is defaulted to the end-user's language.
Parameters
None.
Returns
An empty SearchQuery object with the index and language property already set.
Example
&Portal = %Session.GetPortalRegistry(); &Portal.Open("PORTAL"); &SearchQuery = &Portal.GetSearchQuery();
See Also
Session class: GetSearchQuery method.
The SearchQuery object is used to specify the search index and execute a query against it.
A SearchQuery object is returned by the following:
The GetSearchQuery method from a PortalRegistry object.
The GetSearchQuery method from a Session object.
See PortalRegistry class: GetSearchQuery method.
See Session class: GetSearchQuery method.
In this section, we discuss the SearchQuery class methods.
Syntax
Execute(Start, Size)
Description
The Execute method runs a search query beginning at the document number specified by Start, and returns the number of results (or less) specified by Size in a SearchResult Collection.
Parameters
Start |
Specify the document with which you want to start your query search. This parameter takes an integer, 1 or higher. |
Size |
Specify the number of results that you want returned. This parameter takes an integer value. |
Returns
A SearchResult collection.
Example
&SearchResultCol = &SearchQuery.Execute(1, 20);
See Also
Syntax
Parse()
Description
Use the Parse method to verify the syntax of the query string specified through the QueryText property for syntax errors, such as whether there is a missing quotation mark or closing bracket.
The Parse method does not produce a collection of search results. If there are any errors, it returns a reference to a ParseResult collection that you can search through for errors. If there are not any errors, it returns a Null object.
Parameters
None.
Returns
A reference to a ParseResult collection if there are errors, Null otherwise.
Example
Local ApiObject &MySession; Local ApiObject &ParseResults; Component ApiObject &SearchQuery, &SearchResultCol, &SearchResult; Component Number &Start, &Size; &MySession = %Session; If &MySession Then /* connection is good */ &SearchQuery = &MySession.GetSearchQuery(); &SearchQuery.Indexes = "PSC"; &SearchQuery.Language = %Language; &SearchQuery.QueryText = SEARCH_RECORD.USER_QUESTION.Value; &ParseResults = &SearchQuery.Parse(); If All(&ParseResults) AND &ParseResults.ErrorCount > 0 OR &ParseResults.WarningCount > 0 Then /* Process results */ End-if; End-if;
See Also
In this section, we discuss the SearchQuery class properties. The properties are discussed in alphabetical order.
Description
The HitCount property returns the total number of documents that actually match the query.
This property is read-only.
Description
Use the Indexes property to specify the list of indexes you want the search to query. This list is in the form of a list of comma separated index names. Use the Execute method to execute the query on all the indexes specified in this property.
If you want to search against a single index, specify the index name without any comma.
This property is read-write.
Example
The following example uses two search indexes called CATALOG1 and CATALOG2 for the word "bicycle", with the requested fields called "DESCRIPTION" and "PRICE" in the results.
&sqQuery = %Session.GetSearchQuery(); &sqQuery.Indexes = "CATALOG1, CATALOG2"; &sqQuery.Language = %Language; &sqQuery.Querytext = "bicycle"; &sqQuery.SortSpecifications = "PRICE desc DESCRIPTION asc"; &sqQuery.RequestedFields = "PRICE, DESCRIPTION"; /* Execute the search, getting the first 20 results. */ &srcResults = &sqQuery.Execute(1, 20); If &srcResults <> Null And &srcResults.Count > 0 Then &srCurrent = &srcResults.First(); Repeat Local ApiObject &srFieldColl; &srFieldsColl = &srCurrent.SearchFields; Local ApiObject &srField = &srFieldColl.First(); Repeat /* Do something with this field. */ &srField = &srFieldColl.Next(); Until None(&srField); Until None(&srCurrent); Else ReportSearchAPIErrors(); Local string &msg; &msg = MsgGetText(145, 40, "No results for your search"); End-If; Function ReportSearchAPIErrors() Local ApiObject &msgColl = %Session.PSMessages; Local number &i; For &i = 1 To &msgColl.count Local ApiObject &msg = &msgColl.item(&i); Error (&msg.Text); End-For; &msgColl.DeleteAll(); End-Function;
Description
Note. This property remains for backward compatibility only. Use the Indexes property instead.
See SearchQuery class: Indexes property.
The IndexName property specifies the SearchIndex this query is to retrieve the result from.
You must set this property before a query can be performed on the SearchQuery object returned from the GetSearchQuery method.
This property is read-write.
Example
&SearchQuery.IndexName = "PSA";
Description
Use the KnowledgeBase property to specify a topicset (that is, a file generated by using the mktopics Verity command for a search query. This property takes the name of a file, as a string.
This property is read-write.
Description
The Language property specifies the language of the search index.
The default value for this property is the current user's language.
This property is read-write.
Description
The ProcessedCount property returns the total number of documents that were subjected to the search query.
This property is read-only.
Description
The QueryText property returns the query text to be submitted to the SearchQuery object.
This property is read-write.
Description
The RequestedFields property specifies the set of fields to be returned with the results.
The value of this property is a list of fields, separated by commas.
If this property is not specified, all the fields (except a few internal fields) are returned with the result. You may get better performance by specifying only the fields you want returned.
This property is read-write.
See Also
SortSpecifications, SearchField Collection.
Description
The ScorePrecision property specifies how precise the score should be displayed with the results.
The value of this property is a string, and can be one of the following (case is insensitive)
8bit
16bit
32bit
The system displays two digits after decimal point if "8bit" is selected, and 4 digits if "16bit" is selected. The default value of this property is "8bit".
If this property is set to any other value, the Execute method generates an error and terminates the search.
This property is read-write.
Description
The SortSpecifications property specifies how the results of a search should be sorted.
This property should be in the following format:
fieldname1 {asc | desc} [fieldname2 {asc | desc} ...]
where fieldname1 and fieldname2 are field names to be used to sort the results and asc and desc are keywords for sorting in ascending or descending order.
Specifying multiple fields allows you to perform a secondary sort within the primary sorted results. For example, specifying price asc descr desc sorts the returned results by price in ascending order. Within the price, the results are sorted by descr field in descending order.
The default value of this property is to sort the results by score field in descending order.
Note. If you specify this property, you must also specify the RequestedFields property.
See Also
SearchQuery class: RequestedFields property.
A ParseResult Collection is returned from the Parse SearchQuery method.
See SearchQuery class: Parse method.
In this section, we discuss the ParseResult collection methods. The methods are discussed in alphabetical order.
Syntax
First()
Description
The First method returns the first ParseResult object in the ParseResult collection. If the ParseResult collection is empty, it returns Null.
Example
&MyResult = &MyParseResultCollection.First();
Syntax
Next()
Description
The Next method returns the next ParseResult object in the ParseResult collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
This method returns a Null when there are no more ParseResult objects in the collection.
Parameters
None.
Returns
Either a reference to a ParseResult object, or, if there are no more results in the ParseResult collection, a Null.
Example
Repeat /* &parseInfo.Message() contains the message, process it */ &parseInfo.Next() Until None(&parseInfo);
In this section, we discuss the ParseResult collection properties The properties are discussed in alphabetical order.
Description
The ErrorCount property returns the number of ParseResult objects in this collection with a severity of ERROR.
This property is read-only.
Example
For &I = 1 to &ParseResults.ErrorCount /* process message */ End-For;
Description
The WarningCount property returns the number of ParseResult objects in this collection with a severity of WARNING.
This property is read-only.
A ParseResult object is returned from either the First or Next ParseResult Collection methods.
In this section, we discuss the ParseResult class properties The properties are discussed in alphabetical order.
Description
The Message property returns the text of the error or warning message as a string.
This property is read-only.
Description
The Severity property returns the severity of the message as a string. Values are:
Value |
Description |
ERROR |
Message is an error message. |
WARNING |
Message is a warning message. |
This property is read-only.
A SearchResult collection is returned from the Execute SearchQuery method.
See SearchQuery class: Execute method.
In this section, we discuss the SearchResult collection methods. The methods are discussed in alphabetical order.
Syntax
First()
Description
The First method returns the first SearchResult object in the SearchResult collection. If the SearchResult collection is empty, it returns Null.
Example
&MyResult = &MyCollection.First();
Syntax
Item(number)
Description
The Item method returns the SearchResult object with the position in the SearchResult collection specified by number.
Parameters
Number |
Specify the position number in the collection of the SearchResult object that you want returned. Values start at 1. |
Returns
A SearchResult object if successful, Null otherwise.
Example
For &I = 1 to &MyCollection.Count &MyResult = &MyCollection.Item(&I); /* Do processing */ End-For;
Syntax
Next()
Description
The Next method returns the next SearchResult object in the SearchResult collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MyResult = &MyCollection.Next();
In this section, we discuss the SearchResult collection property Count.
Description
This property returns the number of SearchResult objects in the SearchResult collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
The SearchResult object represents a specific SearchResult in a SearchResult Collection object.
SearchResult objects are instantiated from a SearchResult Collection with the First, ItemByName or Next methods.
In this section, we discuss the SearchResult class properties. The properties are discussed in alphabetical order.
Description
The Key property returns the key for this SearchResult object.
This property is read-only.
Description
The Score property returns the score for this SearchResult object as a string. The decimal separator in this string depends on the Peoplesoft language that was used for search. For example, if you searched in Spanish, the decimal separator would be a ','.
Use this property to display the score.
If you convert this string to a number using the Value function, you might not receive the correct result. This is because the Value function always expects the decimal separator character to be a period. You need to explicitly replace the decimal separator with a period before using the Value function. To avoid such conversion problems, if you want to perform score arithmetic, such as evaluating a score to see if it's below a threshold, use the ScoreAsNumber property.
This property is read-only.
See Also
Description
This property returns the relevancy score as a floating point number between 0 and 1. This property is the same as the Score property, except that this property returns the score as a floating point number instead of a string. Use this value to perform score arithmetic such as comparing it to a threshold value. If you want to display the score, use the Score property.
This property is read-only.
See Also
Description
The SearchFields property returns a SearchField Collection.
This property is read-only.
See Also
A SearchField collection is returned by the SearchFields SearchResult property.
See SearchResult class: SearchFields property.
In this section, we discuss the SearchField collection methods. The methods are discussed in alphabetical order.
Syntax
First()
Description
The First method returns the first SearchField object in the SearchField collection. If the SearchField collection is empty, it returns Null.
Example
&MyField = &MyCollection.First();
Syntax
ItemByName(Name)
Description
The ItemByName method returns the SearchField object specified by Name.
Parameters
Name |
Specify the name of the SearchField you want returned. |
Returns
A SearchField object if successful, Null otherwise.
Example
&MyField = &MyCollection.ItemByName(VALID_TO_DATE);
Syntax
Next()
Description
The Next method returns the next SearchField object in the SearchField collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MyField = &MyCollection.Next();
In this section, we discuss the SearchField collection property Count.
Description
This property returns the number of SearchField objects in the SearchField collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A SearchField is returned by First, ItemByName, and Next SearchField Collection methods.
In this section, we discuss the SearchField class properties. The properties are discussed in alphabetical order.
Description
The Name property returns the name of this SearchField object as a string.
This property is read-only.
Description
The Value property returns the value for this SearchField object as a string.
This property is read-only.
A SearchIndexes collection is returned by the GetSearchIndexes Session class property.
The SearchIndexes in this collection represent all of the logical search indexes that have been created in the PeopleSoft system.
Every search index built and used in a PeopleSoft system must have a logical search index associated with it.
See Session class: GetSearchIndexes method.
In this section, we discuss the SearchIndexes collection methods. The methods are discussed in alphabetical order.
Syntax
First()
Description
The First method returns the first SearchIndex object in the SearchIndexes collection. If the SearchIndex collection is empty, it returns Null.
Example
&MySearchI = &MyCollection.First();
Syntax
ItemByName(Name)
Description
The ItemByName method returns the SearchIndex object specified by Name.
Parameters
Name |
Specify the name of the SearchIndex that you want returned. |
Returns
A SearchIndex object if successful, Null otherwise.
Example
&MySearchI = &MyCollection.ItemByName("MySearchIndex");
Syntax
Next()
Description
The Next method returns the next SearchIndex object in the SearchIndexes collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MySearchI = &MyCollection.Next();
In this section, we discuss the SearchIndex collection property Count.
Description
This property returns the number of SearchIndex objects in the SearchIndexes collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A SearchIndex is returned by First, ItemByName, and Next SearchIndexes Collection methods.
A SearchIndex represents a logical search index, and all the information describing it, in the PeopleSoft system. Every search index built and used in a PeopleSoft system must have a logical search index associated with it.
In this section, we discuss the SearchIndex class method Save.
Syntax
Save()
Description
Use the Save method to save any changes to the search index.
Note. If you change a value of one of the properties of the subobjects (such as some of the search options, and so on) the change won't be written to the database until the SearchIndex object has been saved.
Parameters
None.
Returns
A Boolean value: True if the SearchIndex object is saved successfully, False otherwise.
In this section, we discuss the SearchIndex class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property is used for the spidering search indexes. Parameters that are not covered in the SearchIndex object and its children can be passed to the Verity spidering utility using this property.
This property is read-write.
Description
This property returns a reference to a Search FS Options object, for FSYS type search indexes.
This property is read-only.
See Also
Description
This property returns a reference to a Search HTTP Options object, for HTTP type search indexes.
This property is read-only.
See Also
Description
This property returns a reference to the Search Language collection.
This property is read-only.
See Also
Description
This property specifies the file system location where the search index (collection) is located. You must use a full path name.
This property is read-write.
Description
This property returns the name of the SearchIndex, as a string.
This property is read-only.
Description
This property returns a reference to a SearchRecord Options collection, for RECD type search indexes.
This property is read-only.
See Also
Description
This property returns a reference to the Search Schedule collection.
This property is read-only.
See Also
Description
The Type property specifies the type of index. This property takes a string value. The values are:
Value |
Description |
RECD |
An index generated from a PeopleSoft record |
HTTP |
An index generated from a spider search of the World Wide Web (WWW) |
FSYS |
An index generated from a spider search of a file system |
PRTL |
An index generated from a portal |
USER |
A user defined index (that is, not one of the previous indexes) |
This property is read-write.
A reference to a search record options object is returned by the RecOpts SearchIndex property.
This object is valid only for Search Index types of RECD. These types of indexes are used to index data in a PeopleSoft database. The properties used with this object represent the values that must be set for this type of search index.
See SearchIndex class: RecOpts property.
In this section, we discuss the SearchRecord option class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property returns a reference to a SearchRecordField collection.
The SearchRecordField collection describes the records and fields that are indexed.
The maximum number of fields returned as part of this collection is 50.
This property is read-only.
See Also
Description
This property specifies a filter (that is, a SQL WHERE clause) used to filter out unwanted records from being indexed, as a string.
This property is read-write.
Description
This property specifies a view used for accessing the records that are to be used for incremental indexing, as a string.
This property is read-write.
Description
This property returns the record name for the primary record that the search index is based on. Multiple records can be used, but they must all share a common key structure. The record name returned with this property specifies this common base key structure.
This property is read-only.
Description
This property specifies a replacement pattern for the VdkVgwKey (VeggieKey) used by Verity to uniquely identify a document. The setting of this property determines what is filled in for the unique identifier for each document that gets indexed. Text in this string is replaced with either literal text in the unique identifier or a value determined by one of the following tags:
Tag |
Description |
<pairs/> |
Inserts a string of NAME=VALUE; pairs for each key on the Record being indexed |
<row/> |
Inserts the Record keys in a SQL-like syntax |
<field fieldname='MYFIELD'/> |
Inserts the value of MYFIELD for the Row being indexed (if it exists in the record; an error occurs when you save the data if it is missing) |
<sql stmt='SQL STATEMENT'/> |
Inserts the value returned by the SQL statement. Only the first row returned is accepted. SQL statements that return more than one column cause an error at runtime. |
To use these tags, you include them as part of the VeggieKey string. The indexing process replaces them with values. For example, given the following Row of data:
Record: PROD_SRCH Field: PRODUCTID=A11111 (a key on the record) Field: DESCR="Baby goldfish" Field: PRICE=5.00
You could produce any of the following unique identifiers with various settings of VeggieKey:
VeggieKey Setting |
String Produced |
"<pairs/>" |
"PRODUCTID=A11111;" |
"SELECT * FROM <row/>" |
"SELECT * FROM PS_PROD_SRCH WHERE PRODUCTID='A11111'" |
"<pairs/> <field filedname='DESCR'/>" |
"PRODUCTID=A11111; Baby goldfish" |
"Total price: <sql stmt='SELECT SUM(PRICE) FROM PS_PROD_SRCH'/>" |
"Total price: 550.78" |
Note that the last example is not truly unique, although it is legal. It is up to the application to make sure that the setting of VeggieKey produces a unique string for each indexed document, as the indexing process does not perform this check. Applications that use VdkVgwKey to identify the results of search queries cannot find the correct document if the documents do not have a unique key.
This property is read-only.
Description
This property specifies the zone option for the index as a string. Values are:
Value |
Description |
ONE |
All the fields for each row of data are inserted into the same zone in the word index. This is a simple scheme which does not allow you to search only parts of the word index but may be appropriate for applications without easily-differentiated text regions. |
FLD |
One zone is created for each field. The data in that field for each row is inserted into the same zone. This enables applications to search only a specific part of the word index at a time, with a potential performance gain. This does not happen automatically, however; the query interface built by the application must support searching in specific zones. The name of the zone created is the name of the field. The build process may take longer with this option set. |
This property is read-only.
A SearchRecordField collection is returned from the Fields SearchRecord Options property.
The SearchRecordField collection describes the records and fields that are indexed.
The maximum number of fields returned as part of this collection is 50.
See SearchRecord Options class: Fields property.
In this section, we discuss the SearchRecordField collection methods. The methods are discussed in alphabetical order.
Syntax
DeleteItem(Record, Field)
Description
Use the DeleteItem method to delete the SearchRecordField specified by the record and field name.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
Parameters
Record |
Specify a record name as a string. |
Field |
Specify a field name as a string. |
Returns
A Boolean value: True, item was deleted successfully, False otherwise.
Syntax
First()
Description
The First method returns the first SearchRecordField object in the SearchRecordField collection. If the SearchRecordField collection is empty, it returns Null.
Example
&MySearchField = &MyCollection.First();
Syntax
InsertItem(Record, Field)
Description
Use the InsertItem method to insert a SearchRecordField object into the SearchRecordField collection.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
If the item you are trying to insert already exists, this method returns Null.
Parameters
Record |
Specify a record name as a string. |
Field |
Specify a field name as a string. |
Returns
A reference to a new SearchRecordField object if successful, Null otherwise.
Syntax
ItemByName(Record, Field)
Description
The ItemByName method returns the SearchRecordField object specified by the record and field name.
Parameters
Record |
Specify a record name as a string. |
Field |
Specify a field name as a string. |
Returns
A SearchRecordField object if successful, Null otherwise.
Example
&MySearchField = &MyCollection.ItemByName("SEARCH", "DATE");
Syntax
Next()
Description
The Next method returns the next SearchRecordField object in the SearchRecordField collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MySearchOpts = &MyCollection.Next();
In this section, we discuss the SearchRecordField collection property Count.
Description
This property returns the number of SearchRecordField objects in the SearchRecordField collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A SearchRecordField is returned by the First, ItemByName, InsertItem, and Next SearchRecordField collection methods.
A SearchRecordField object describes the records and fields that are indexed.
See SearchRecordField Collection.
In this section, we discuss the SearchRecordField class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property returns the field name for this SearchRecordField as a string.
This property is read-only.
Description
This property specifies whether the search record field is an attachment. This property takes a Boolean value: True, the field is an attachment, False otherwise.
This property is read-write.
Description
This property specifies whether the search record field is a Verity field. This property takes a Boolean value: True, the field is a Verity field, False otherwise.
This property is read-write.
Description
This property specifies whether the search record field is a word index. This property takes a Boolean value: True, the field is a word index, False otherwise.
This property is read-write.
Description
This property returns the name of the record as a string.
This property is read-only.
A reference to a Search Language collection is returned by the Languages property.
See SearchIndex class: Languages property.
In this section, we discuss the Search Language collection methods. The methods are discussed in alphabetical order.
Syntax
DeleteItem(Name)
Description
Use the DeleteItem method to delete the Search Language specified by Name.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
Parameters
Name |
Specify the name of the Search Language that you want to delete. |
Returns
A Boolean value: True, item was deleted successfully, False otherwise.
Syntax
First()
Description
The First method returns the first Search Language object in the Search Language collection. If the Search Language collection is empty, returns Null.
Example
&MyLang = &MyCollection.First();
Syntax
InsertItem(LanguageCode, MapLanguageCode)
Description
Use the InsertItem method to insert a Search Language object into the Search Language collection.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
If the item you are trying to insert already exists, this method returns Null.
Parameters
LanguageCode |
Specify a language code as a string. |
MapLanguageCode |
Specify a language code to map LanguageCode to (typically this is the same as LanguageCode). |
Returns
A reference to a new Search Language object if successful, Null if not successful.
Syntax
ItemByName(LanguageCode)
Description
The ItemByName method returns the Search Language object specified by LanguageCode.
Parameters
LanguageCode |
Specify the language code of the object that you want to retrieve. |
Returns
A reference to a Search Language object if successful, Null otherwise.
Example
&MyLang = &MyCollection.ItemByName("ENG");
Syntax
Next()
Description
The Next method returns the next Search Language object in the Search Language collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MyLang = &MyCollection.Next();
In this section, we discuss the Search Language collection property Count.
Description
This property returns the number of Search Language objects in the Search Language collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A reference to a Search Language object is returned by the First, ItemByName, InsertItem, and Next Search Language Collection methods.
See Search Language Collection.
In this section, we discuss the Search Language class properties. The properties are discussed in alphabetical order.
Description
This property specifies the language code for the Search Language object as a string.
This property is read-only.
Description
Specify a language code to map the given language to (typically this is the same as LanguageCode).
This property is read-only.
A reference to a Search Schedule collection is returned by the Schedules SearchIndex property.
See SearchIndex class: Schedules property.
In this section, we discuss the Search Schedule collection methods. The methods are discussed in alphabetical order.
Syntax
DeleteItem(Name)
Description
Use the DeleteItem method to delete the Search Schedule specified by Name.
This method is not executed automatically. It is executed only when the SearchIndex is saved.
Parameters
Name |
Specify the name of the Search Schedule that you want to delete. |
Returns
A Boolean value: True, item was deleted successfully, False otherwise.
Syntax
First()
Description
The First method returns the first Search Schedule object in the Search Schedule collection. If the Search Schedule collection is empty, this method returns Null.
Example
&MySch = &MyCollection.First();
Syntax
InsertItem(RunCntrlID)
Description
Use the InsertItem method to insert a Search Schedule object into the Search Schedule collection.
This method is not executed automatically. It is executed only when the SearchIndex is saved.
If the item you are trying to insert already exists, this method returns Null.
Parameters
RunCntrlId |
Specify the run control ID of the search schedule object as a string. |
Returns
A reference to a new Search Schedule object if successful, Null if not successful.
Syntax
ItemByName(RunCntrlId)
Description
The ItemByName method returns the Search Schedule object specified by RunCntrlId.
Parameters
RunCntrlId |
Specify the run control ID of the search schedule object as a string. |
Returns
A Search Schedule object if successful, Null otherwise.
Example
&MySchedule = &MyCollection.ItemByName("MySched");
Syntax
Next()
Description
The Next method returns the next Search Schedule object in the Search Schedule collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MySched = &MyCollection.Next();
In this section, we discuss the Search Schedule collection property Count.
Description
This property returns the number of Search Schedule objects in the Search Schedule collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A reference to a Search Schedule object is returned by the First, ItemByName, InsertItem, and Next Search Schedule Collection methods.
See Search Schedule Collection.
In this section, we discuss the Search Schedule class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property specifies how you want the index rebuilt with this schedule item. Values are:
Value |
Description |
INCR |
Incremental updates an existing index. Use this schedule item for indexes with small amounts of data, and for cleaning up large indexes periodically when they start to fragment. |
RBLD |
Rebuild deletes the index and starts from scratch. Use this to add to an existing, large index. |
This property is read-write.
Description
This property returns the Run Control ID associated with the schedule item.
This property is read-only.
Description
This property specifies the name of the Recurrence Definition as a string. For example: "Daily Search Rebuild".
This property is read-write.
See Also
Description
This is the name of the Process Scheduler Server that processes the requests for this schedule item, for example, "PSNT".
This property is read-write.
See Also
A reference to a Search HTTP Options object is returned by the HTTPOpts SearchIndex property.
This object is valid only for Search Index types of HTTP. These types of indexes spider URLs. The properties available using this object represent values that must be set for spidering URL's.
See SearchIndex class: HTTPOpts property.
In this section, we discuss the Search HTTP Option class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property is used to cause the HTTP Spider Gateway to descend HTTPS (SSL) links and HTTP links when it builds the index. This property takes a Boolean value: True, use the HTTPS (SSL) links, False otherwise.
This property is read-write.
Description
This property limits spidering (indexing) to the specified domain. This property takes a string value.
This property is read-write.
Description
This property specifies a list of filename "globs" which the indexing process uses to filter its list. The GlobListType determines how the filtering is done. The value of this property is a space-separated list of filenames with or without wildcards. The following is an example of the value for this property:
"*.doc *.txt *.html robots.txt"
This property is read-write.
See Also
Search HTTP Options class: GlobListType property.
Description
This property determines how the values specified with GlobList are used. Values are:
Value |
Description |
ALL |
Ignore the values specified with GlobList. Index all filenames encountered regardless of their pattern. |
EXC |
Exclude the values specified with GlobList. Index everything except names that match a pattern in GlobList. |
INC |
Include the values specified with GlobList. Index only filenames that match a pattern in GlobList and exclude all other filenames. |
This property is read-write.
See Also
Search HTTP Options class: GlobList property.
Description
This property determines how many links the HTTP Spider descends from its starting point as a number.
A value of 1, for example, indexes the original page as well as the documents linked to by that page, and then stop.
A value of 2 indexes the original page, and documents linked to it, as well as documents linked to by the second page.
PeopleSoft recommends not setting this value over 10 without combining it with the DomainLimit property as the amount of data retrieved into the index increases geometrically with the LinkDepth.
This property is read-write.
See Also
Search HTTP Options class: DomainLimit property.
Description
This property is used in a similar fashion to GlobList. It is a space-separated list of MIME Types. The MIMEListType determines how they affect indexing. The following is an example of a value for this property:
"text/html text/plain application/*"
This property is read-write.
See Also
Search HTTP Options class: MIMEListType property, GlobList property.
Description
This property is used like GlobListType, but applies to MIMEList instead of GlobList. Instead of testing the pattern of the filename, this property tests the MIME-type detected for the document when determining whether to index it.
This property is read-write.
See Also
Search HTTP Options class: MIMEList property, GlobListType property.
Description
This property specifies the hostname or IP address of the HTTP proxy, if the HTTP Spider Gateway needs an HTTP proxy to connect to remote websites during the indexing process.
This property is read-write.
Description
This property specifies the port number of the HTTP proxy set in ProxyHost as a number.
This property is read-write.
Description
This property returns a reference to a Search Start Options collection.
This property is read-only.
See Also
Search Start Options Collection.
A reference to a Search FS Options object is returned by the FSOpts SearchIndex property.
This object is valid only for Search Index types of FSYS. These types of indexes spider a file system. The properties available using this object represent the values that must be set for spidering a file system.
See SearchIndex class: FSOpts property.
In this section, we discuss the Search FS Option class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
This property specifies a list of filename "globs" which the indexing process uses to filter its list. The GlobListType determines how they affect indexing. The value of this property is a space-separated list of filenames with or without wildcards. The following is an example of the value for this property:
"*.doc *.txt *.html robots.txt"
This property is read-write.
See Also
Search FS Options class: GlobListType property.
Description
This property determines how the values specified with GlobList are used. Values are:
Value |
Description |
ALL |
Ignore the values specified with GlobList. Index all filenames encountered regardless of their pattern. |
EXC |
Exclude the values specified with GlobList. Index everything except names that match a pattern in GlobList. |
INC |
Include the values specified with GlobList. Index only filenames that match a pattern in GlobList and exclude all other filenames. |
This property is read-write.
See Also
Search FS Options class: GlobList property.
Description
This property is used like GlobList. It is a space-separated list of MIME Types. The MIMEListType determines how they affect indexing. The following is an example of the value for this property:
"text/html text/plain application/*"
This property is read-write.
See Also
Search FS Options class: MIMEListType property, GlobList property.
Description
This property is used like GlobListType, but applies to MIMEList instead of GlobList. Instead of testing the pattern of the filename, this property tests the MIME-type detected for the document when determining whether to index it.
This property is read-write.
See Also
Search FS Options class: MIMEList property, GlobListType property.
Description
This property returns a reference to a Search Start Options collection.
This property is read-only.
See Also
Search Start Options Collection.
The values in the Search Start Options Collection get passed to the −start parameter of the Verity spider utility. These values represent the starting points for spidering.
A Search Start Option collection is returned from:
StartOpts Search HTTP Options class property
StartOpts Search FS Options class property
See Search HTTP Options Class property
See Search HTTP Options class: StartOpts property.
See Search FS Options Class property
See Search HTTP Options class: StartOpts property.
In this section, we discuss the Search Start Options collection methods. The methods are discussed in alphabetical order.
Syntax
DeleteItem(Value)
Description
Use the DeleteItem method to delete the Search Start Options specified by Value.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
Parameters
Value |
Specify the value of the Search Start Option that you want to delete. |
Returns
A Boolean value: True, item was deleted successfully, False otherwise.
Syntax
First()
Description
The First method returns the first Search Start Options object in the Search Start Options collection. If the Search Start Options collection is empty, this method returns Null.
Example
&MySearchOpts = &MyCollection.First();
Syntax
InsertItem(Value)
Description
Use the InsertItem method to insert a Search Start Options object into the Search Start Options collection.
This method is executed immediately, however, the values are updated in the database only when the SearchIndex is saved.
If the item you are trying to insert already exists, this method returns Null.
Parameters
Value |
Specify the value of the Search Start Option that you want to insert. |
Returns
A reference to a new Search Start Option object if successful, Null if not successful.
Syntax
ItemByName(Value)
Description
The ItemByName method returns the Search Start Options object specified by Value.
Parameters
Value |
Specify the value of the Search Start Options that you want returned. |
Returns
A Search Start Options object if successful, Null otherwise.
Example
&MySearchOpts = &MyCollection.ItemByName("MyStartOptions");
Syntax
Next()
Description
The Next method returns the next Search Start Options object in the Search Start Options collection. You can use this method only after you have used the First method: otherwise the system doesn't know where to start.
Example
&MySearchOpts = &MyCollection.Next();
In this section, we discuss the Search Start Options collection property Count.
Description
This property returns the number of Search Start Options objects in the Search Start Options collection, as a number.
This property is read-only.
Example
&COUNT = &MY_COLLECTION.Count;
A reference to a Search Start object is returned by the First, ItemByName, InsertItem, and Next Search Start Options Collection methods.
See Search Start Options Collection.
In this section, we discuss the Search Start Options class properties. The properties are discussed in alphabetical order.
Note. If you change a value of one of the properties, the change won't take effect until the SearchIndex object has been saved.
Description
The value of this property is passed to the −domain option of the Verity spider utility. This property specifies whether the domain is restricted. This property takes a Boolean value: True, the domain is restricted, False otherwise.
This property is read-write.
Description
This property specifies whether the host is restricted. This property takes a Boolean value: True, the host is restricted, False otherwise.
This property is read-write.
Description
This property returns the value of the Search Start Options, as a string.
This property is read-only.
The following PeopleCode programs are examples of how to use the Search API.
The following is a general example uses two search indexes called CATALOG1 and CATALOG2 for the word "bicycle", with the requested fields called "DESCRIPTION" and "PRICE" in the results.
&sqQuery = %Session.GetSearchQuery(); &sqQuery.Indexes = "CATALOG1, CATALOG2"; &sqQuery.Language = %Language; &sqQuery.Querytext = "bicycle"; &sqQuery.SortSpecification = "PRICE desc DESCRIPTION asc"; &sqQuery.RequestedFields = "PRICE, DESCRIPTION"; /* Execute the search, getting the first 20 results. */ &srcResults = &sqQuery.Execute(1, 20); If &srcResults <> Null And &srcResults.Count > 0 Then &srCurrent = &srcResults.First(); Repeat Local ApiObject &srFieldColl; &srFieldsColl = &srCurrent.SearchFields; Local ApiObject &srField = &srFieldColl.First(); Repeat /* Do something with this field. */ &srField = &srFieldColl.Next(); Until None(&srField); Until None(&srCurrent); Else ReportSearchAPIErrors(); Local string &msg; &msg = MsgGetText(145, 40, "No results for your search"); End-If; Function ReportSearchAPIErrors() Local ApiObject &msgColl = %Session.PSMessages; Local number &i; For &i = 1 To &msgColl.count Local ApiObject &msg = &msgColl.item(&i); Error (&msg.Text); End-For; &msgColl.DeleteAll(); End-Function;
The following is a Portal search example.
&SearchKey = %Request.GetParameter("SEARCH_TEXT"); &StartPosition = %Request.GetParameter("START_POSITION") SearchResultChunkSize = 1000; /*----------------------------------------------------------------------------- Get a portal registry object. ------------------------------------------------------------------------------*/ &Portal = %Session.GetPortalRegistry(); /*----------------------------------------------------------------------------- Open the desired portal. ------------------------------------------------------------------------------*/ &Portal.Open("PORTAL") /*---------------------------------------------------------------------------- Get a search query object. ------------------------------------------------------------------------------*/ &SearchQuery = &PORTAL.GetSearchQuery(); /*---------------------------------------------------------------------------- Set the text of the query the user entered ------------------------------------------------------------------------------*/ &SearchQuery.QueryText = &SearchKey /*---------------------------------------------------------------------------- Execute the search passing in the starting position and "chunk size" (get me the first 20 result or the third 20) ------------------------------------------------------------------------------*/ &SearchResultsColl = &SearchQuery.Execute(&StartPosition, &SearchResultChunkSize); /*---------------------------------------------------------------------------- Get the first result. ------------------------------------------------------------------------------*/ &SearchResult = &SearchResultsColl.First(); While (&SearchResult <> Null) /*--------------------------------------------------------------------------- Example of getting the key. In the portal case, the key is the URL, but in the general case it could be a product id or some kind of other database key. ---------------------------------------------------------------------------*/ &SearchKey = &SearchResult.Key; /*--------------------------------------------------------------------------- Example of getting the Field. In the portal case, the field is the URL. Yes, it is redundant with the key but the key includes some {} around the URL and this just makes it easier to get the URL. ---------------------------------------------------------------------------*/ &URLSearchField = &SearchResult.SearchFields.ItemByName("URL") &URL = &URLSearchField.Value /*--------------------------------------------------------------------------- Another example of a field using dot notation to simplify the code. ---------------------------------------------------------------------------*/ &ContentProvider = &SearchResult.SearchFields.ItemByName("ContentProvider").Value /*--------------------------------------------------------------------------- Call a function to insert the result into the page. ---------------------------------------------------------------------------*/ AddStuffToPage(&URL, &ContentProvider); /*--------------------------------------------------------------------------- Get the next result of the search. ---------------------------------------------------------------------------*/ &SearchResult = &SearchResultsColl.Next(); End-While; &Portal.Close();