0

I have a federated location via OpenSearch 1.0/1.1 that I want to search programmatically. Can I programmatically make my own search box where I can post the search word as a variable and a date variable from a eg. jQuery datepicker and process the data to my federated location?

1 Answer 1

0

Yes you can use SearchServiceApplicationProxy and QueryManager

SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy
(SPServiceContext.GetContext(SPContext.Current.Site));
LocationConfiguration[] locationConfigs;
LocationConfiguration locationConfig = null;
locationConfigs = proxy.GetLocationConfigurations(out lastupdate, out crawl);
Location location;
LocationList locationList = new LocationList();
QueryManager queryManager = new QueryManager();
foreach (LocationConfiguration locConfig in locationConfigs)
{
    if (locConfig.InternalName.Equals("LocalSearchIndex"))
    {
         locationConfig = locConfig;
         break;
    }
}
location = new Location(locationConfig.InternalName, proxy);
location.UserQuery = queryText;
locationList.Add(location);
queryManager.Add(locationList);
queryManager.IsTriggered(locationList);
XmlDocument xDoc = queryManager.GetResults(locationList);
DataSet resultSet = new DataSet();
resultSet.ReadXml(new XmlNodeReader(xDoc));

Check this msdn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.