Tuesday, July 22, 2008

Search Using FAST Search API

FAST Enterprises Search API gives the interface to communicate with the ESP(Enterprises Search Platform) Admin.The following way we can do the search.


1. We need the ESP Admin server IP address/ Domain Name and Port Number.

EX : String host = "172.19.61.104";
String port = "15100";

2. Then Indentify the Collection where the data's resides.

EX : String viewName = "espsystemwebcluster";

Note :The Collection Should be create in ESP Admin bfeore run the program.

3. Create the Property file to create a seasrch Factory Instances.
EX :
Properties p = new Properties();
p.setProperty("com.fastsearch.esp.search.SearchFactory",
"com.fastsearch.esp.search.http.HttpSearchFactory");
p.setProperty("com.fastsearch.esp.search.http.qrservers", hostport);

ISearchFactory searchFactory = SearchFactory.newInstance(p);

Note :qrservers - A list of QRServers that you want to connect to.It's Mandatory Property.You can map multiple servers in the same type like "qrserver1.site.com:15100, qrserver2.site.com:15100".

HttpSearchFactory - It have Some other Optional Proerties.
RequestMethod -> "GET"/"POST" (Default : "GET")
CertiticateFile -> When Use the SSL Certificate
KeepAlive -> When use the Prsistance Connections is used.

4. Once the Search Factory Instances has been created,we can get the Views of the collection.Using this view Object ,we can do the search.

EX : ISearchView view = searchFactory.getSearchView(viewName);

5. FAST ESP API give the multiple of ypes of Search Option.You can set the option with the FAST Search Query.By default ESP have their own Query Language (FQL).

EX : String query = query.replaceAll("\"", "\\\"");
String fql = "string(\"" + query + "\", mode=simpleany)";

Mode - Specifies the search option.

6. Using IQuery interface we can create the FQL Query.

EX : IQuery theQuery = new Query(fql);

7. The Pass this query to view object ,it will return the Result set.

Ex : IQueryResult result = view.search(theQuery);

This Result Interface have all the documents which is related to your query.