0
votes

I'm trying to query the sharepoint search with the following code

    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;

    }

And no matter what i do i get this exception: Exception from HRESULT: 0x80040E01

23-07-2012 14:53:45 Documenten Search System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] Exception from HRESULT: 0x80040E01

Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Office.Server.Search.Query.ISearchQueryServiceApplication.Execute(QueryProperties properties) at Microsoft.Office.Server.Search.Administration.SearchServiceApplicationProxy.<>c_DisplayClass4.b_3(ISearchServiceApplication serviceApplication) 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.Execute() at Rapportages.RapportageDocumenten.RapportageDocumenten.Search(String query, SPWeb currentWeb)

I read suggestions i should reduce the rowlimit, but i get this exception even with a rowlimit as low as 20.

1
According to this, remove the setting of RowLimit. stackoverflow.com/questions/4073206/…Daniel A. White
Unfortunately, that did not change anything. still Exception from HRESULT: 0x80040E01Oaden

1 Answers

0
votes

Putting the fulltextsqlquery in a using fixed the issue. Don't ask me why.

                   using (FullTextSqlQuery q = GetFullTextSqlQuery(web))
                    {
                        q.QueryText = sqlQuery.ToString();
                        rt = ((ResultTableCollection)q.Execute())[ResultType.RelevantResults];
                        Logging.LogMessage(rt.RowCount.ToString());
                    }