我正在尝试使用以下代码查询sharepoint搜索
protected ResultTable Search(String query, SPWeb currentWeb)
{
ResultTable rt = null;
try
{
FullTextSqlQuery q = GetFullTextSqlQuery(currentWeb);
q.QueryText = query;
q.RowLimit = int.MaxValue;
rt = ((ResultTableCollection)q.Execute())[ResultType.RelevantResults];
//q.Dispose();
}
catch (Exception ex)
{
rt = null;
Logging.LogException(ex);
}
return rt;
}
/// <summary>
/// Create base FullTextSqlQuery
/// </summary>
/// <returns>FullTextSqlQuery</returns>
protected static FullTextSqlQuery GetFullTextSqlQuery(SPWeb currentWeb)
{
FullTextSqlQuery q = new FullTextSqlQuery(currentWeb.Site);
q.Culture = new CultureInfo(1033);
q.EnableStemming = false;
q.TrimDuplicates = true;
if (SPSecurity.AuthenticationMode != System.Web.Configuration.AuthenticationMode.Windows)
{
q.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
}
else
{
q.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;
}
q.RowLimit = 200;
q.StartRow = 0;
q.IgnoreAllNoiseQuery = false;
q.ResultTypes = ResultType.RelevantResults;
return q;
}
无论我做什么,我都会遇到此异常:来自HRESULT的异常:0x80040E01
23-07-2012 14:53:45 Documenten Search System.ServiceModel.FaultException`1 [System.ServiceModel.ExceptionDetail]来自HRESULT的异常:0x80040E01
服务器堆栈跟踪: 在System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息回复,MessageFault错误,字符串操作,MessageVersion版本,FaultConverter faultConverter) 在System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime操作,ProxyRpc&amp; rpc) 在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout) 在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作) 在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
在[0]处重新抛出异常:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData,Int32 type)
在Microsoft.Office.Server.Search.Query.ISearchQueryServiceApplication.Execute(QueryProperties属性)
在Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy。&lt;&gt; c_ DisplayClass4.b _3(ISearchServiceApplication serviceApplication)
在Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoSpLoadBalancedUriWsOp [T](WebServiceBackedOperation 1 webServiceCall, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, String operationName)
at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.DoWebServiceBackedOperation[T](String operationName, Int32 timeoutInMilliseconds, Int32 wcfTimeoutInMilliseconds, WebServiceBackedOperation
1个webServiceCall)
在Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.Execute(QueryProperties属性)
在Microsoft.Office.Server.Search.Query.Query.Execute()
在Rapportages.RapportageDocumenten.RapportageDocumenten.Search(字符串查询,SPWeb currentWeb)
我读到了建议我应该减少rowlimit,但即使rowlimit低至20,我也会得到这个异常。
答案 0 :(得分:0)
将fulltextsqlquery置于使用中修复了该问题。不要问我为什么。
using (FullTextSqlQuery q = GetFullTextSqlQuery(web))
{
q.QueryText = sqlQuery.ToString();
rt = ((ResultTableCollection)q.Execute())[ResultType.RelevantResults];
Logging.LogMessage(rt.RowCount.ToString());
}