none
How to form a querystring for the FAST search API? RRS feed

  • Question

  • Hello all,

    In our intranet company, we have a Sharepoint FASTSearch working good.  No complaint at all.  Now, we want to expand the search to other internal websites.  We create a form and send the query to the search results.  

    Here is the form syntax:

    <form method=”get” action=http://search.company.com/results.aspx>
    	<input type=”text” name=”k” value=” Enterprise Search” size=”18” />
    	<input type=”hidden” name=”site” value=”http:// the site to be searched” />
    	<input type=”image” name=”btnSearch” src=”/_images/searchbutton.gif” />
    </form>
    
    


    Is it correct syntax? Especially for the site param.  I looked into the internet and some articles use u parameter for site..... (http://msdn.microsoft.com/en-us/library/aa637082.aspx)

    Thanks

    John.

     

    • Moved by star.wars Friday, November 11, 2011 9:44 AM Fast search question (From:SharePoint - Search (pre-SharePoint 2010))
    Monday, November 7, 2011 11:29 PM

Answers

  • Hi John,

    (and this is actually not FAST specific, but relates to oob SharePoint search as well).

    The "site" parameter has to be part of the query itself, not a separate parameter. If you did:

    k=Enterprise Search site:http://mysite

    then it would restrict on your site. Using the "u" parameter is the way to go as a separate parameter, and it will be rewritten to "site:" inside the webpart when executing the query. So change your hidden input field from "site" to "u".

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    • Proposed as answer by Thomas SvensenModerator Monday, November 14, 2011 1:44 PM
    • Marked as answer by JP_L Monday, January 9, 2012 6:57 PM
    Sunday, November 13, 2011 11:23 AM

All replies

  • Hi John,

    It is a fast search question, I will move it there.

    Thanks


    Regards, Daniel
    Friday, November 11, 2011 9:43 AM
  • Hi John,

    (and this is actually not FAST specific, but relates to oob SharePoint search as well).

    The "site" parameter has to be part of the query itself, not a separate parameter. If you did:

    k=Enterprise Search site:http://mysite

    then it would restrict on your site. Using the "u" parameter is the way to go as a separate parameter, and it will be rewritten to "site:" inside the webpart when executing the query. So change your hidden input field from "site" to "u".

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    • Proposed as answer by Thomas SvensenModerator Monday, November 14, 2011 1:44 PM
    • Marked as answer by JP_L Monday, January 9, 2012 6:57 PM
    Sunday, November 13, 2011 11:23 AM
  • Hi Mikael,

    Thanks for your response.   As you proposed, here is the correct syntax:

    http://search.company.com/results.aspx?k=keywordSearchHere&u=http://mysite
    


    I have done some testing and it doesn't seem to be returning correct results.  

    What if the I want to refine to a specific shared folder?  What is the correct syntax if you know by chance, Mikael?

    I guess this type of question should be asked very often or at least it is documented somewhere in SharePoint/FAST site....  Quite surprised!!!

     

    Once again, thank you much for your help

    John.





    Monday, November 14, 2011 6:15 PM
  • Hi John,

    You can see my post on creating refiner parameters by code for some POC code on this, and read the comments as well.

    How are you not seeing correct results? Are you comparing to using the refiner for site in the UI and getting different results compared to the "u=" parameter?

    -m


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, November 14, 2011 7:19 PM
  • Are you comparing to using the refiner for site in the UI and getting different results compared to the "u=" parameter?

    Yes, that is correct.  I tried using this method to compare the results.  Using refiner with the "u=" and the results are different.  I notice that in the refiner url, it is encoded as:

    the "u=" value has been encrypted so I have no clue what the real value is.

     

    http://sharepointsite/Pages/results.aspx?k=searchkeywordsample&u=%22AR0BZmlsZTovL253L0NhYmluTmV0d29ya1N5c3RlbXMIc2l0ZW5hbWUBASIBIg%3D%3D%22

     

    the "u=" value has been encrypted so I have no clue what the real value is.

     

    I will check out your post and see if I can understand a bit more.

     

    Once again, pls accept my sincere thank.

    John.

     

    Monday, November 14, 2011 7:44 PM
  • Hi John,

    If I'm not totally off today it translates as: sitename = "file://nw/CabinNetworkSystems"

    It's base64 encoded. If you run an online base64 decoder on the string:

    AR0BZmlsZTovL253L0NhYmluTmV0d29ya1N5c3RlbXMIc2l0ZW5hbWUBASIBIg==

    you would get the result. (%3D translates to =, and #22 to ", which I removed), and then you have to split it.

    Regards,
    Mikael Svenson 

     


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, November 14, 2011 9:22 PM