none
Programatically accessing fast search result RRS feed

  • Question

  • HI

    I have configured fast search on my local which is stand alone server.I created one fast query service.In that i created scope but the scope is not displaying any result.Even when I search using keyword query I get  no empty result.

    My code is:

    var query = new KeywordQuery(web.Site)
                    {
                        QueryText = "Article"
                       
                                   };
      var queryResults = query.Execute();                 var queryResultsTable = queryResults[ResultType.RelevantResults];                 results.Load(queryResultsTable, LoadOption.OverwriteChanges);

     I am using sharepoint object model and keywordquery to get the result programatically but I am getting error .so is there anywhere any document where I can know how to access search result of this fast query search  programmatically.

    Another thing is if there is any good documentation regarding fast search integration and implementation using object model on sharepoint 2010 that will also be welcome?

    Thanks


    • Edited by agarwal Thursday, September 29, 2011 7:55 AM Updated question with more details
    • Moved by Shimin Huang Friday, September 30, 2011 9:22 AM (From:SharePoint 2010 - Using Visual Studio with SharePoint and other programming)
    Thursday, September 29, 2011 7:26 AM

Answers

  • HI

    In the above code when I changed the below line

      ResultTable  queryResultsTable = queryResults[ResultType.RelevantResults];

    to the

     query.ResultTypes = ResultType.RelevantResults;
    

    then i start getting the result But now another issue what I am facing is regarding scope.The scope which I have created in query ssa shows 0 value when I add rule although the item are there However  in the above code when I give

    QueryText=scope:\"Article\"
    

    I get the result table but when I change this query to fql as follows

     
    QueryText=filter(scope:equals(""Article"")) query.EnableFQL = true;

    then I get error "Scope in your query does not exist" so I am not able to understand why is it happening ?

    Monday, October 3, 2011 1:22 PM
  • Hi,

    Ah, I should have spotted the ResultTypes line :)

    As for using Scopes in your query with FQL, this is not supported. When setting the query mode to FQL, you basically bypasses all query expanding like scopes and synonyms. The reason for your error is that there are no managed property named "scope". If you want query expansion features which is part of SharePoint you have to stick to using KQL.

    (Scopes will also always be empty when viewed in SharePoint against FAST, and I recommend reading http://technet.microsoft.com/en-us/library/ff805053.aspx)

    You can however program the functionality yourself, and I have code to do this at spsearchparts.codeplex.com which you could take a look at.

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, October 3, 2011 4:40 PM
  • Hi agarwal

     

    You would need to do a full crawl, not just an incremental crawl, for your new managed property to be populated propery.

     

     


    Thomas Svensen | Microsoft Consulting Services
    • Marked as answer by agarwal Wednesday, October 5, 2011 4:53 AM
    Tuesday, October 4, 2011 11:56 PM
    Moderator

All replies

  • Hi agarwal,

    This is a fast search question, so I will move it to Fast Search forum, developers in that forum will provide you more help .

    Thanks,
    Simon

    Friday, September 30, 2011 9:20 AM
  • Hi,

    When creating scopes for FAST using the UI make sure to follow the guideline at http://technet.microsoft.com/en-us/library/ff453895.aspx. But I strongly recommend using PowerShell instead, as it's generally easier, and also more flexible. The above link has a reference to how to create scopes with PowerShell for FAST.

    As for using the KeywordQuery class. Have you made sure to set the Query SSA as the default SSA in your application proxy group (Central Admin). You can also add:

    query.SearchProvider = SearchProvider.FASTSearch;
    

    to make sure you target FAST.

    If you want to go a step further look into how to use FQL as your query language instead of KQL. (Corey Roth has a tutorial on his blog).

    FQL reference can be found at: http://msdn.microsoft.com/en-us/library/ff394606.aspx

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Friday, September 30, 2011 6:10 PM
  • HI Mikael

     

    I have made sure that the query ssa is my default ssa. I am getting result through UI in my site collection but not through code.

    Moreover what I noticed that result which I am getting in UI is mix of redundant data and my proper data what I mean is that i had some data in one sitecollection  and I crawled it but then I deleted the whole web application and created new fresh webapplication on same port so I wen to content ssa and I reset the crawled through central admin and then recrawled the whole site.In crawl logs when i see then I see that it has crawled properly but when I search result on the site then it shows old result which was present in deleted site.

     Is the crawl index reset doesn't reset the content properly or am I missing some step?

     

    Saturday, October 1, 2011 6:56 AM
  • Hi,

    The redundant data is probably easy fix. Clearing the index with FAST is a two step process. First you clear the crawler database vi Central Admin which you already did (this will not remove the search index itself), then you have to use PowerShell (or code) to clear the actual index on the FAST farm. It's all detailed at TechNet.

    When you search with code, what error are you getting?

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Sunday, October 2, 2011 9:01 PM
  •    SearchQueryAndSiteSettingsServiceProxy settingsProxy =
                  SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
                    var searchProxy = settingsProxy.ApplicationProxies
                        .OfType<SearchServiceApplicationProxy>()
                        .Where(proxy => proxy.FASTAdminProxy != null)
                        .FirstOrDefault();
    
       var query = new KeywordQuery(searchProxy)
                    {
                        QueryText = "article"
             
                    };
    
        ResultTableCollection  queryResults = query.Execute();//here  Only I get my result as null so when the next line is executed I get the result as {"The given key was not present in the dictionary."}
               
                   ResultTable  queryResultsTable = queryResults[ResultType.RelevantResults];
    

    Above is my code which I am using it to get the result programatically.But I am not getting any result in it.

    Please see the code if there is any issue in it

    Monday, October 3, 2011 5:20 AM
  • HI

    In the above code when I changed the below line

      ResultTable  queryResultsTable = queryResults[ResultType.RelevantResults];

    to the

     query.ResultTypes = ResultType.RelevantResults;
    

    then i start getting the result But now another issue what I am facing is regarding scope.The scope which I have created in query ssa shows 0 value when I add rule although the item are there However  in the above code when I give

    QueryText=scope:\"Article\"
    

    I get the result table but when I change this query to fql as follows

     
    QueryText=filter(scope:equals(""Article"")) query.EnableFQL = true;

    then I get error "Scope in your query does not exist" so I am not able to understand why is it happening ?

    Monday, October 3, 2011 1:22 PM
  • Hi,

    Ah, I should have spotted the ResultTypes line :)

    As for using Scopes in your query with FQL, this is not supported. When setting the query mode to FQL, you basically bypasses all query expanding like scopes and synonyms. The reason for your error is that there are no managed property named "scope". If you want query expansion features which is part of SharePoint you have to stick to using KQL.

    (Scopes will also always be empty when viewed in SharePoint against FAST, and I recommend reading http://technet.microsoft.com/en-us/library/ff805053.aspx)

    You can however program the functionality yourself, and I have code to do this at spsearchparts.codeplex.com which you could take a look at.

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, October 3, 2011 4:40 PM
  • Thanks Mikael for the answer

    One more question

    I created managed properties under fast search administartion>Managed Proeprties.But this property returns null even after crawling.I did incremental crawl but no effect.

    the property type which I am creating is boolean and I added mapping to my Boolean custom column but it is not showing any value.

    Do I need to configure something to get the values in these managed property?

     

    Tuesday, October 4, 2011 2:47 PM
  • Hi agarwal

     

    You would need to do a full crawl, not just an incremental crawl, for your new managed property to be populated propery.

     

     


    Thomas Svensen | Microsoft Consulting Services
    • Marked as answer by agarwal Wednesday, October 5, 2011 4:53 AM
    Tuesday, October 4, 2011 11:56 PM
    Moderator