I'm trying to use the search for sharepoint 2013 so I use searchExecutor. My issue is when I execute this line, I get an exception

ResultTableCollection searchResults = searchExecutor.ExecuteQuery(kquery);

Here is the complete example

// get the query and settings service proxy
                SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
                // get the search service application proxy by name
                SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("Search Service Application");

                KeywordQuery kquery = new KeywordQuery(searchProxy);
                kquery.IgnoreAllNoiseQuery = false;
                kquery.ResultsProvider = SearchProvider.Default;
                kquery.RowsPerPage = Convert.ToInt32(itemPerPage);
                kquery.RowLimit = Convert.ToInt32(itemPerPage);
                kquery.StartRow = (currentPage * Convert.ToInt32(itemPerPage)) + 1;
                string[] cols = queryCol.Split(';');
                foreach (string c in cols)
                kquery.QueryText = strKey.Trim();
                int ce = kquery.SortList.Count;
                switch (dir.ToLower())
                    case "ascending":
                        kquery.SortList.Add(colSort, Microsoft.Office.Server.Search.Query.SortDirection.Ascending);
                    case "descending":
                        kquery.SortList.Add(colSort, Microsoft.Office.Server.Search.Query.SortDirection.Descending);
                //kquery.ResultTypes |= ResultType.RelevantResults;
                //ResultTableCollection searchResults = kquery.Execute();
                //ResultTable queryResultsTable = searchResults[ResultType.RelevantResults];
                SearchExecutor searchExecutor = new SearchExecutor();
                Utils.writeDBLog("", "searchExecutor","" );
                ResultTableCollection searchResults = searchExecutor.ExecuteQuery(kquery);
                Utils.writeDBLog("", "searchResults", "");
                var queryResultsTables = searchResults.Filter("TableType", KnownTableTypes.RelevantResults);
                Utils.writeDBLog("", "queryResultsTables", "");
                var resultTable = queryResultsTables.FirstOrDefault();
                Utils.writeDBLog("", "resultTable", "");

                DataTable dtTemp = resultTable.Table;

                //DataTable dtTemp = new DataTable();
                //dtTemp.Load(queryResultsTable, LoadOption.OverwriteChanges);
                sourceDataTable = CompleteDatatable(dtTemp);
                //nbResult = queryResultsTable.TotalRows;
                nbResult = resultTable.TotalRows;
                Utils.writeDBLog("", "nbResult", "nbResult: " + nbResult);

In SharePoint 2010, I used the line in comment and it worked correctly but in 2013 it's obsolete so I want to use searchExecutor.

For information I get this in my catch block

La recherche a rencontré un problème qui empêche de renvoyer les résultats. Si le problème persiste, contactez votre administrateur. - at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.ThrowGenericQueryException(String operationName) at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoSpLoadBalancedUriWsOp[T](WebServiceBackedOperation1 webServiceCall, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, String operationName) at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoWebServiceBackedOperation[T](String operationName, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, WebServiceBackedOperation1 webServiceCall) at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.Execute(QueryProperties properties) at Microsoft.Office.Server.Search.Query.Query.ExecuteQuery() at Microsoft.Office.Server.Search.Query.SearchExecutor.ExecuteQueryInternal(Query query) at Microsoft.Office.Server.Search.Query.SearchExecutor.ExecuteQuery(Query query) at SearchResultSP.SearchResultWP.SearchResultWP.GetData()

I'm disapointed and I don't understand why it doesn't work

Thanks for your help


I would dissect your query to determine the issue. Pare it down to a simple query. Remove the sorting, for example. Then watch the ULS Logs while the query executes. The SORTING processing has changed in 2013 and may be the root of your problem. There should be an error in ULS logs that tells you what is going wrong.

  • thanks i gonna check this when i'm in office. Do you have a exemple for the new sorting in 2013? – bender Mar 31 '14 at 9:14
  • To begin with, you have to specify "sortable" as an attribute of your managed properties before the crawl. – Matthew McDermott Mar 31 '14 at 21:24
  • all my meta are sortable but still doesn't work. When i put the switch for sorting in comment, the search works – bender Apr 1 '14 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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