Programmer's Guide:
Using Search in Rooms and Facilities

You can search for items in a single Room or across multiple Rooms in a Facility. To search for items in one Room, get the Room Searcher object from the Room. To search for items in multiple rooms in a Facility, get the Facility Searcher object from the Facility. You can search every Room in the facility to which the logged-in user has access, or just the Rooms you specify.

You can use Room Searcher and Facility Searcher queries to find specific text, items created on a certain date or in a particular time period, or items created by particular members. A query searches all parts of all pages within a Room - such as text, titles, and comments - as well as the contents of File objects.

The properties of the IERUSearchCriteria interface let you narrow a search, whether you are searching a single Room or an entire Facility:

Property

Description

Date1

Indicates the first date in a date-constrained search. For example, the date on which an item was created or the first in a series of dates on which an item could have been created.

Date2

Indicates the second date in a date-constrained search. For example, the last in a series of dates on which an item could have been created.

DateOp

Indicates a date operator for Date1 and Date2 in a date-constrained search. For example, you can search for items created on, before, or after a specified date.

KeywordExpression

Indicates a search string that found items must contain.

Member

Indicates the owner of the item for which you want to search. Must be used in conjunction with the Ownership property.

Ownership

Indicates whether to search for items based on Users or Groups who appear in an object's "who can edit" list.

Options

Indicates search options. In this release, you can use this property to search for items that are marked as unread.

Searching an entire Facility


The following example searches all Rooms in the Facility for all items that contain the phrase "Release 3.0."

Dim Mgr As New ERUSvrManager
Dim Facility as IERUFacility Dim Searcher As IERUFacilitySearch
Dim Criteria as IERUSearchCriteria
Dim Items As IERUCollection
Dim Item As IERUItem

Set Facility = Mgr.GetFacility("http://localhost/eroom/fac7", "user", "password", "", "")

'Get the a Facility Searcher object.
Set Searcher = Facility.Searcher

'Set search criteria to all items that contain the phrase specified by FindPhrase.
Set Criteria = Searcher
Criteria.KeywordExpression = "Release 3.0"

'Execute the search.
Set Items = Searcher.Execute

Searching selected Rooms


The following example searches three specific Rooms for items created by a particular user.

Dim Mgr As New ERUSvrManager
Dim Facility as IERUFacility
Dim Searcher As IERUFacilitySearch
Dim Criteria as IERUSearchCriteria
Dim Items As IERUCollection
Dim Item As IERUItem

Set Facility = Mgr.GetFacility("http://localhost/eroom/fac7", "user", "password", "", "")

'Get the Facility Searcher object.
Set Searcher = Facility.Searcher

'Get the rooms we want to search and tell the Facility Searcher
Set Room1 = Mgr.GetRoom("http://localhost/eroom/fac7/room3", "user", "password", "", "")
Set Room2 = Mgr.GetRoom("http://localhost/eroom/fac7/room4", "user", "password", "", "")
Searcher.AddRoom(Room1)
Searcher.AddRoom(Room2)

'Set search criteria to all items created by the logged-in user
Set Criteria = Searcher
Criteria.Owner = Facility.LoggedInMember

'Execute the search.
Set Items = Searcher.Execute

Searching a single Room


The following example searches a Room for all items created earlier than one week ago and deletes them.

Dim SvrManager As New ERUSvrManager
Dim Room As IERURoom
Dim Searcher As IERURoomSearch
Dim Criteria as IERUSearchCriteria
Dim WeekAgo As Date
Dim Items As IERUCollection
Dim Item As IERUItem

Set Room = SvrManager.GetRoom("http://localhost/eroom/fac7/room1", "user", "password", "", "")

'Get the Room Searcher object.
Set Searcher = Room.Searcher

'Set search criteria to all Items created before the date specified by WeekAgo.
WeekAgo = DateAdd("ww", -1, Date)
Set Criteria = Searcher
Criteria.Date1 = WeekAgo
Criteria.DateOp = erDateOperBefore

'Execute the search.
Set Items = Searcher.Execute

'Delete each Item in the returned collection.
For Each Item In Items
Item.Delete
Next

Searching based on Custom Fields


For information on searching for items based on their custom field values, see Using eRoom Custom Fields.