开发者

Difference between KeywordQuery, FullTextQuerySearch type for Object Model and Web service Query

Initially I believed these 3 to be doing more or less the same thing with just the开发者_运维技巧 notation being different. Until recently, when i noticed that their does exists a big difference between the results of the KeyWordQuery/FullTextQuerySearch and Web service Query.

I used both KeywordQuery and FullText method to search of the the value of a customColumn XYZ with value (ASDSADA-21312ASD-ASDASD):-

When I run this query as:- 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);

I get the following result representing the document.

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

Do note the Path and isDocument fields of the above result.

Web Service Method

Then I tried a Web Service Query method. I used Sharepoint Search Service Tool available at http://sharepointsearchserv.codeplex.com/ and ran the same query i.e. Select title, path, author, isdocument from scope() where freetext('ASDSADA-21312ASD-ASDASD'). This time I got the following results:-

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

Again note the path. While the search results from 2nd method are useful as they provide me the file path exactly, I can't seem to understand why is the method 1 not giving me the same results?

Why is there a discrepancy between the two results?


The first item is a List item, not a document per se. A document library is essentially just another list that is specially made to hold documents in it. The list item likely has some extra metadata not held within the document and so on. The second result is the actual document, so the "isDocument" flag will be up for it.

At least that's my theory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜