SharePoint 2010 FreeTextSqlQuery “Your query is ma

2019-03-06 14:07发布

I am attempting to run a FullTextSqlQuery. But I keep getting the error "Your Query is malformed". Any ideas on what is causing it to break?

       FullTextSqlQuery sqlQuery = new FullTextSqlQuery(currentSite);
                sqlQuery.ResultTypes = ResultType.RelevantResults;
                sqlQuery.TrimDuplicates = true;
                sqlQuery.StartRow = 1;
                sqlQuery.RowLimit = int.MaxValue;
                sqlQuery.HighlightedSentenceCount = 3;
                sqlQuery.KeywordInclusion = KeywordInclusion.AnyKeyword;
                sqlQuery.EnableStemming = true;
                sqlQuery.SiteContext = new System.Uri(currentSite.Url);
                sqlQuery.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;


                //sqlQuery.QueryText = BuildFullTextSQLSearchString(keyword);

                sqlQuery.QueryText = @"SELECT Title, Path, HitHighlightedSummary, Size, Rank, IsDocument, DocumentIcon, DocType, AuthInd, RequiresNDA, ProductLine, FileExtension 
FROM portal..SCOPE()
WHERE CONTAINS('""test""') AND (""SCOPE"" = 'Software Downloads')
ORDER BY Rank DESC, Title ASC";

                ResultTableCollection queryResults = sqlQuery.Execute();

1条回答
Animai°情兽
2楼-- · 2019-03-06 15:06
  • removing the "Portal.." from the query solved the "Your query is malformed" error.

    string fromClause = "FROM portal..SCOPE() ";

  • setting the rowlimit to int.MaxValue, was causing an error to be thrown: This was causing an error "Exception from HRESULT: 0x80040E01"

    sqlQuery.RowLimit = int.MaxValue;

  • removing the "Title ASC" from the order by clause, prevented the error "Exception from HRESULT: 0x80040E60". string

    orderByClause = "ORDER BY Rank DESC, Title ASC";

查看更多
登录 后发表回答