locked
Access Visual Best Bets results programmatically in FAST search RRS feed

  • Question

  • Hello,

    I am working in FAST Search environment and want to retrieve Visual Best bets results programmatically.

    I wrote following code, but it is not returning any results. 

     SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();

     SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("FAST Query SSA");

     KeywordQuery keywordQuery = new KeywordQuery(searchProxy);

     keywordQuery.EnableFQL = true;

     keywordQuery.QueryText = "deployment";

     keywordQuery.ResultsProvider = SearchProvider.FASTSearch;

     keywordQuery.ResultTypes = ResultType.VisualBestBetsResults;

     ResultTableCollection resultsTableCollection = keywordQuery.Execute();

     ResultTable searchResultsTable = resultsTableCollection[ResultType.VisualBestBetsResults];

     DataTable resultsDataTable = new DataTable();

     resultsDataTable.TableName = "Results";

     resultsDataTable.Load(searchResultsTable, LoadOption.OverwriteChanges);

     gridViewFQL.DataSource = resultsDataTable;
     
     gridViewFQL.DataBind();
     
    For ResulType = RelevantResults it is returning proper results.

    Can anyone help me to identify what is wrong in the above code

    Thanks

    Monday, October 17, 2011 3:08 PM

Answers

All replies

  • Hi,

    The code is correct and I've had issues with the same as well. Both best bets and visual best bets seems to fail via the KeywordQuery api, unless there is some magic to it which we somehow is missing. The same code works fine against the built-in search for best bets.

    One note though on your code. EnableFql should be set to false, as the best bets won't work for fql queries.

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, October 17, 2011 7:22 PM
  • Hi,

    I was able to figure it out. You have to set the "UserContextGroupID" property of the KeywordQuery class.

    Sample can be found at http://techmikael.blogspot.com/2011/12/returning-best-bets-and-visual-best.html

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    • Proposed as answer by Thomas Svensen Wednesday, December 14, 2011 11:55 AM
    • Marked as answer by rshah1812 Monday, December 19, 2011 11:16 AM
    Tuesday, December 13, 2011 10:14 PM
  • Thanks Mikael, I shall try the solution and let you know if I face any other issue.
    • Marked as answer by rshah1812 Monday, December 19, 2011 11:16 AM
    • Unmarked as answer by rshah1812 Monday, December 19, 2011 11:18 AM
    Wednesday, December 14, 2011 8:26 AM