0

我创建了一个 xml 查询,我将其发送到我的共享点搜索服务,该服务正在返回一些结果。然后我从中提取 SQL 查询文本并开始将其与对象模型一起使用,但现在它无法正常工作。根据下面的代码,看起来我做错了什么吗?

查询 XML(返回结果):

<QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000">
                                    <Query domain="QDomain">
                                     <SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats>
                                     <Context>
                                       <QueryText language="en-US" type="MSSQLFT"><![CDATA[ SELECT Title, Rank, owsPublished1,owsSocialx0020Networkx0020Update, Description, Write, Path FROM scope()   ORDER BY "Rank" DESC ]]></QueryText>
                                     </Context>
                                     <Range><StartAt>1</StartAt><Count>20</Count></Range>
                                     <EnableStemming>false</EnableStemming>
                                     <TrimDuplicates>true</TrimDuplicates>
                                     <IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery>
                                     <ImplicitAndBehavior>true</ImplicitAndBehavior>        <IncludeRelevanceResults>true</IncludeRelevanceResults>                               <IncludeSpecialTermResults>true</IncludeSpecialTermResults>                        
<IncludeHighConfidenceResults>true</IncludeHighConfidenceResults>
                                    </Query></QueryPacket>

对象模型代码(没有):

        SPSite site = new SPSite("http://sp-dev/");
        ServerContext sc = ServerContext.GetContext(site);
        FullTextSqlQuery ftq = new FullTextSqlQuery(sc);
        string querySQL = @"SELECT Title, Rank, owsPublished1,owsSocialx0020Networkx0020Update, Description, Write, Path FROM scope()   ORDER BY ""Rank"" DESC ";

        ftq.QueryText = querySQL;;
        ResultTableCollection results = ftq.Execute();
4

1 回答 1

2

您至少需要添加:

ftq.EnableStemming = false;
ftq.TrimDuplicates = true;
ftq.IgnoreAllNoiseQuery = true;
ftq.KeywordInclusion = KeywordInclusion.AllKeywords;

至少在这两种方法之间进行公平的比较。然后,您还可以尝试:

ftq.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
于 2010-12-03T13:46:00.377 回答