KeywordQuery,对象模型的FullTextQuerySearch类型和Web服务查询之间的区别

时间:2010-06-01 10:48:38

标签: sharepoint search sharepoint-2010

最初,我认为这三种做法或多或少是相同的,只是符号不同。直到最近,当我注意到它们确实存在KeyWordQuery / FullTextQuerySearch和Web服务查询的结果之间存在很大差异。

我使用KeywordQuery和FullText方法搜索具有值的customColumn XYZ的值(ASDSADA-21312ASD-ASDASD): -

当我运行此查询时: - FullTextSqlQuery: -

            FullTextSqlQuery myQuery = new FullTextSqlQuery(site);
            {
                // Construct query text
                String queryText = "Select title, path, author, isdocument from scope() where freetext('ASDSADA-21312ASD-ASDASD') ";

                myQuery.QueryText = queryText;
                myQuery.ResultTypes = ResultType.RelevantResults;
            };


            // execute the query and load the results into a datatable
            ResultTableCollection queryResults = myQuery.Execute();
            ResultTable resultTable = queryResults[ResultType.RelevantResults];

            // Load table with results
            DataTable queryDataTable = new DataTable();
            queryDataTable.Load(resultTable, LoadOption.OverwriteChanges);

我得到以下代表文档的结果。

* Title: TestPDF 
* path: http://SharepointServer/Shared Documents/Forms/DispForm.aspx?ID=94 
* author: null 
* isDocument: false 

请注意上述结果的Path和isDocument字段。

网络服务方法

然后我尝试了一种Web服务查询方法。我使用了http://sharepointsearchserv.codeplex.com/提供的Sharepoint Search Service Tool并运行相同的查询,即从scope()中选择title,path,author,isdocument,其中freetext('ASDSADA-21312ASD-ASDASD')。这次我得到了以下结果: -

* Title: TestPDF 
* path: http://SharepointServer/Shared Documents/TestPDF.pdf  
* author: null 
* isDocument: true 

再次注意路径。虽然第二种方法的搜索结果很有用,因为它们准确地为我提供了文件路径,但我似乎无法理解为什么方法1没有给我相同的结果?

为什么两个结果之间存在差异?

1 个答案:

答案 0 :(得分:0)

第一项是List项,而不是文档本身。文档库本质上只是另一个列表,专门用于保存文档。列表项可能包含一些未在文档中保留的额外元数据,依此类推。第二个结果是实际文档,因此“isDocument”标志将为它启动。

至少那是我的理论。

相关问题