Saturday, January 18, 2014

Using KeywordQuery In sharepoint

If you want to limit the KeywordQuery to current site only, use the HiddenConstraints property.
Following is an example:


string siteName = SPContext.Current.Site.RootWeb.Title;

SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy
       (SPServiceContext.GetContext(SPContext.Current.Site));
            KeywordQuery query = new KeywordQuery(proxy);
            query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
            query.QueryText = queryText;
            query.HiddenConstraints = "This Site: " + siteName + "";
            query.ResultTypes |= ResultType.RelevantResults;



References:




No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...