To build a new connector, you will need Visual Studio 2003 or above. The tutorial is created using Visual Studio 2005.
1. Load your copy of Visual Studio
2. Project> New >Create a new project, go to File
3. Select your preferred language and create a Class Library
4. Add the ISYS.Federator.dll as a reference to the project. In the solution explorer, right-click and select Add Reference. Change to the Browse tab, and navigate to the Perceptive Enterprise Search folder. Select the ISYS.Federator.dll and click OK.
You are now ready to begin creating your federated connector. We will extend the Class1 object to implement our logic. First, add a using clause to the top of the file:
using ISYS.Federator;
Now we can begin to implement our federated connector object, replace the Class1 declaration with the following code:
publicclassMyFederatedConnector : Federator
{
publicoverridevoid Execute(ISYSFederatorRequest Request, ISYSFederatorResponse Response)
{
thrownewException("The method or operation is not implemented.");
}
}
This is the minimum function set that must be implemented to create a connector. In this scenario, the default query translation will take place, all we have to implement is the results translation.
We will create a very simple connector for demonstration purposes, this example connects to the Microsoft LiveSearch to execute a search and fetches the results as an RSS feed. The RSS is then unpacked into the ISYSFederatorResponse object.
We extend our Execute method to have the following:
public override void Execute(ISYSFederatorRequest Request, ISYSFederatorResponse Response) { String sURL = "http://beta.search.msn.com/results.aspx?format=rss&q="; // Append our translated query to the URL, make sure that it is // correctly URL encoded sURL += System.Web.HttpUtility.UrlEncode(Request.Query.ToString()); // Load the live search data into an XML document System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(sURL); // Walk the resulting RSS feed XmlNodeList items = xmlDoc.SelectNodes("//item"); foreach (XmlNode child in items) { Response.AddResult(); Response.CurrentItem.SetAttribute(Attributes.Title, getNodeValue(child, "title")); Response.CurrentItem.SetAttribute(Attributes.HREF, getNodeValue(child, "link")); Response.CurrentItem.SetAttribute(Attributes.URL, getNodeValue(child, "link")); Response.CurrentItem.SetAttribute(Attributes.Summary, getNodeValue(child, "description")); Response.CurrentItem.SetAttribute(Attributes.Date, getNodeValue(child, "pubDate")); } } // Utility function to assist getting the text out of child node private string getNodeValue(XmlNode item, string name) { XmlNode child = item.SelectSingleNode("./" + name); if (child != null) return child.InnerText; else return ""; }
Compile the project taking note of the output DLL file location. To test the connector, we must first create the connector configuration file. Open up notepad and create the following:
ISYSfederator name=â€MyConnectorâ€<>
driver type=â€.net†class=â€MyFederatedConnector†module=â€c:\pathtomodule.dll†/<>
/ISYSfederator<>
You will need to provide the fully qualified path to your DLL in the module attribute.
Save this file in the Perceptive Enterprise Search\WebFederator directory as “MyConnector.xmlâ€.
You can now add the connector via the Perceptive Enterprise Search Administration Console, navigate to the Perceptive Enterprise Search Administration Console:
1. on the home page Indexes Click
2. button New Index Click the
3. button Next and click the Federated Source Select
4. button. Next †(or the name you specified in the XML file) and click theMyConnectorSelect “
5. button. Next button. If your connector is functioning correctly, you will see results returned. If you are satisfied with the results, click the Test There are no configuration options, so you will now be able to test the connector. Enter a search and click the
6. button. Next Give this instance of the connector a name, this is the name shown to the user at search time then click the
7. to create the new source. Finish Review your settings, and then click
Your users will now be able to search the federated connector on the search site. If you do not see the connector as one of the search options, you may need to add it to the website’s indexes. This can be found in the administration console under:
[Site Name]WebSites\\Search Settings\Indexes