1

I am facing an issue in SharePoint search, when I am using SharePoint default UI to search, it is showing different set of results and when I am searching using search object model, it is showing a different set of results. I am using the below code:

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;
4
  • What are the differences? Make sure to only look at the "Relevant Resuls" returned from your KQL above Jun 24, 2014 at 12:57
  • difference in items in result, it seems both results are coming from different sources. In CA, there are multiple content sources. Jun 24, 2014 at 13:42
  • You might want to check if the any permission change. It worth to do full crawl and see if the search results are now consistent
    – Supermode
    Jun 25, 2014 at 4:30
  • At Site level, There are three scopes 1. All Sites 2. People 3. MyCustomScope. when i am using search object model, it is showing data from 'All Sites' scope but my requirement is to show resulrs from 'MyCustomSearch' scope. Please help Jun 25, 2014 at 9:11

2 Answers 2

0

In the case its SharePoint 2013: I would suggest to compare the results with the awesome Search Query Tool (https://sp2013searchtool.codeplex.com/) - there you can impersonate as different users, target scopes and more.

0

Below code helped me

ServerContext context = ServerContext.GetContext(SPContext.Current.Site);
FullTextSqlQuery qrySearch = new FullTextSqlQuery(context);
//Specifies the results set containing the main search results from the content index matching the search query.
qrySearch.ResultTypes = ResultType.RelevantResults;
qrySearch.EnableStemming = true;
qrySearch.TrimDuplicates = false;
qrySearch.QueryText = "SELECT SubCategory,ReferenceName,DocType,MainCategory,URL,Title, HitHighlightedSummary FROM SCOPE() where \"scope\"='<Name of Scope Here>' And FREETEXT(*,'" + queryText + "')";
ResultTableCollection results = qrySearch.Execute();

Your Answer

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

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