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

Posted by Raghu on Stack Overflow See other posts from Stack Overflow or by Raghu
Published on 2010-06-01T10:48:38Z Indexed on 2010/06/01 10:53 UTC
Read the original article Hit count: 335

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about search