Help > ContextCogs > Creating ContextCogs > Creating a Script ContextCog

Creating a Script ContextCog

Script Cogs give you a simple way of injecting content without the need for a development environment. Perceptive Enterprise Search allows you to create a VB script that is executed for each search. The scripts can be as simple or as complex as you like.

Script ContextCogs have a single requirement; they must implement a function with the following declaration:

Function Process(Request)

The passed in Request object contains the incoming query and also the output.

Request Object

The request object contains the following properties and methods:

Property Request.Query as String

Read-only - Contains the query as it was entered by the user.

Property Request.Response as String

Set to the output of the cog. This must be XML if used in conjunction with an XSLT file; otherwise you can specify HTML directly. It's recommended that you use an XSLT, as it allows you to separate the business logic from the presentation logic.

Property Request.Score as Integer

Indicates the score for this connector; the cog with the highest score is the cog that will be shown with the search results. Your context cog should be conservative with its scoring, as to not override a cog that may be more relevant. For example, the Contacts cog produces a high score if it directly hits on a person's name, where the Wikipedia cog produces a lower score.

Example

See ExpressionEvaluator.vbs in Perceptive Enterprise Search\WebCogs folder for a complete sample.