none
Fast Query Language (FQL) example !!!!!!!!!!! RRS feed

  • Question

  • Hi,

    I need an example of FQL, from where I can learn FQL syntax, using FQL in custom webpart using c# etc.

    Regards,

    Mehar
    Saturday, July 2, 2011 8:04 PM

Answers

  • Hello Mehar,

    The fql would look something like this (haven't tested it):

    and(
    	string("my query", mode="simpleall"),
    	or(
    		path:starts-with("http://localhost/sites/first"),
    		path:starts-with("http://localhost/sites/three")
    	)
    )

    I added line breaks for readability

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Thursday, July 7, 2011 8:51 PM

All replies

  • Bump
    Sunday, July 3, 2011 3:21 PM
  • Hello Mehar,

    First off, using numerous exclamation points in the header is considered bad practice and will not help you get an answer any sooner.

    Your #1 place for reference material is Microsoft TechNet and MSDN. As for FQL there is section called FQL Syntax Reference where you can start reading at: http://msdn.microsoft.com/en-us/library/ff394606.aspx

    When you have specific questions as how you want to use fql, then ask a new specific question on that :)

    As for using FQL in a webpart, the easiest approach is to use the KeywordQuery class. The key point is to set EnableFQL to true.

    You can take a look at ProfileExtensions.zip at my SkyDrive for example usage. It's sample code to a presentation I did in February.

    Regards,
    Mikael Svenson 


    Search Enthusiast - MCTS SharePoint/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, July 4, 2011 11:34 AM
  • Hello Mikael,

    Can we configure a custom developed search web-part to display search contents in SahrePoint result.aspx page.

    Regards,

    Mehar

    Monday, July 4, 2011 7:15 PM
  • Hello Mikael,

    Can we configure a custom developed search web-part to display search contents in SahrePoint result.aspx page.

    Regards,

    Mehar

    Yes you can. Could you tell a bit more about what you are trying to accomplish?

    Regards,
    Mikael Svenson 


    Search Enthusiast - MCTS SharePoint/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Monday, July 4, 2011 7:23 PM
  • I have to develop a search webpart that will contain i) Search Box, 2) Some checkboxes just below checkbox (to narrow the search).

    I also want the search box look same as SharePoint default search box is with All Site, People, Advance etc options.

    Regards,

    Mehar

    Monday, July 4, 2011 8:05 PM
  • Hi Mehar,

    You can keep the original search box and pick up the query parameters from the url in your custom web part.

    keyword -> k=

    scope -> s= 

    Are you developing a complete custom web part or inheriting from the Core Results Web Part?

    Regards,
    Mikael Svenson 


    Search Enthusiast - MCTS SharePoint/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Wednesday, July 6, 2011 1:56 PM
  • Hi Mikael.

    I am developing complete custom web part, I decided to  build fql query and pass to result.aspx

    Which keyword I will use only to display results from specific site collections ?

    Suppose I have three site collections

    i) http://localhost/sites/first

    ii) http://localhost/sites/second

    iii) http://localhost/sites/third

    And I want to search for a specific string only from site http://localhost/sites/first and http://localhost/sites/three.

    Regards,

    Mehar

    Wednesday, July 6, 2011 6:53 PM
  • Hello Mehar,

    The fql would look something like this (haven't tested it):

    and(
    	string("my query", mode="simpleall"),
    	or(
    		path:starts-with("http://localhost/sites/first"),
    		path:starts-with("http://localhost/sites/three")
    	)
    )

    I added line breaks for readability

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Thursday, July 7, 2011 8:51 PM
  • Hi Mikael,

    Can you suggest me some E-Book / forum from where I can learn writing FQL.

     

    Regards

    Mehar

    Friday, July 8, 2011 4:48 AM
  • Hello Mehar,

    I wish I could, but I haven't seen any sample page with a lot of examples. There are a few in the fql reference on TechNet http://msdn.microsoft.com/en-us/library/ff394606.aspx, but it takes a bit of trial an error.

    The FAST ESP docs has more samples regarding this in a document called ESP_Query_Language_Parameters_Guide.pdf if have access to it.

    Regards,
    Mikael Svenson 


    Search Enthusiast - SharePoint MVP/WCF4/ASP.Net4
    http://techmikael.blogspot.com/
    Sunday, July 10, 2011 9:04 PM
  • Hi Mikael Svenson,

          Can you please tell me the correct format of FQL which has path appended to the query string as what you mentioned in the above post. I tried it but it is showing as query malformed error.  I want a correct FQL query (path appended to query string) so that i can use it.  Please help me ..


    Sharath Kumar R



    Tuesday, August 21, 2012 9:31 AM
  • Hi,

    Can you post the query you have right now, and we'll try to help you sort it out.

    Thanks,
    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    Friday, August 24, 2012 7:30 AM
  • Hi,

          I am making use of this link http://msdn.microsoft.com/en-us/library/gg588339.aspx (Step:2).  There i am using the FQL string as 

    "and(string("keyword", mode=\"simpleany\")" +"," + "path:'http://abc.com/xyz'" +")" 

        Here the path is a filter. If the path is given as "path:'abc.com'", then results are refining.

    But if we give path:'http://abc.com/xyz', then it is showing query malformed error. So how to pass a path url with "/" characters appended to it.


    Sharath Kumar R

    Thursday, August 30, 2012 11:52 AM
  • Hi,

    Seems your escaping etc is a bit off. Try the code below.

    string keyword = "some keyword";
    string path = "http://yourpath";
    string fql = "and(string(\"" + keyword + ",mode=\"simpleany\"), path:\"" + path + "\")";
    Thanks,
    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    • Proposed as answer by kumar sharath Monday, September 3, 2012 10:29 AM
    Thursday, August 30, 2012 6:20 PM
  • Hi Svenson,

      Thanks for your reply. It worked. Can you do me one more help. I need to sort two manage properties. In keyword Query class, it is possible.

    But in FQL, can you please tell me the syntax how to pass two manage properties "abc" and "xyz". If I am sorting through manage property "abc" ,then I will use below code.

    "<SortByProperties>" + "<SortByProperty name=" +

    "\"" + "abc" + "\""

    + " direction=\"Descending\"></SortByProperty>" +

    But I need to sort two manage properties. Please help me..Thanks!


    Sharath Kumar R

    Monday, September 24, 2012 11:21 AM
  • Hi,

    You have to add your properties to the SortList property of the KeywordQuery class.

    For example (p320 of Working with FS4SP):

    // sort on date
    kq.SortList.Add("write", SortDirection.Descending);
    // If dates are the same, sort on rank
    kq.SortList.Add("default", SortDirection.Descending);

    Thanks,

    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    • Proposed as answer by kumar sharath Monday, October 1, 2012 12:56 PM
    Monday, September 24, 2012 11:54 AM
  • Hi Svenson,

      Thanks for your quick reply. Can you please tell me the FQL query equivalent as I am not using keyword query class. 

    How to sort two manage properties using FQL.? Thanks.


    Sharath Kumar R

    Monday, September 24, 2012 12:40 PM
  • Hi,

    You cannot sort using FQL. Which API are you using for your queries?

    Thanks,
    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    Monday, September 24, 2012 1:00 PM
  • HI Svenson,

      I am making use of Query Web Service class..We are able to sort one manage property say "abc"  but how to sort two manage properties.

    Is that not possible ha?

    "<SortByProperties>" +
    "<SortByProperty name=" + "\"" + "abc" + "\"" + " direction=\"Descending\"></SortByProperty>" +


    Sharath Kumar R

    Monday, September 24, 2012 2:41 PM
  • Hi Kumar,

    By looking at the xml you write you should be able to figure it out :) If not, take a look at the documentation at http://msdn.microsoft.com/en-us/library/ms568268.aspx. Hint: the xml has structure where the parent nodes name is in plural form. This again leads to the convention of having one or more child nodes. Agree?

    Thanks,
    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    Tuesday, September 25, 2012 6:25 AM
  • Hello,

    how you display search contents in SharePoint result.aspx page using custom developed search web-part?


    • Edited by BhaveshM Friday, October 12, 2012 4:01 PM
    Friday, October 12, 2012 4:00 PM
  • Hi Mehar,

    You can check FQL example on below mentioned URL.... To build FQL query there is one tool MOSS MAN.  You can download from codeplex site

    http://fastforsharepoint.codeplex.com/

    Thanks !!

    Dharm

    Saturday, March 2, 2013 3:06 AM
  • Hi Mikael,

    We are planning to migrate from FAST ESP to SharePoint 2013 Search.We have a webservice in FAST ESP which makes uses of Fast Query Language(FQL) to query & retrieve results from FAST server. FQL is also supported in SP 2013 but we implement it using KeywordQuery class. It is mentioned in the below link that keywordQuery class and members are oboselete and will be deprecated in O16. Is there any alternative to implement FQL in SP 2013 other than using KeywordQuery class. 

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.query.keywordquery.aspx

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.search.query.keywordquery_members.aspx  

    Tuesday, June 25, 2013 7:06 AM
  • Hi,

    Depending on what FQL features you are using you can rewrite the queries to KQL. KQL in 2013 includes more operators and have better boolean support with parenthesis. (http://msdn.microsoft.com/en-us/library/ee558911.aspx)

    The KeywordQuery class you list is obsolete, but http://msdn.microsoft.com/en-us/library/microsoft.office.server.search.query.keywordquery.aspx is not. It's a matter of using the right one from the right namespace :) So you can still use the KeywordQuery class going forward.

    Thanks,
    Mikael Svenson


    Search Enthusiast - SharePoint MVP/MCT/MCPD - If you find an answer useful, please up-vote it.
    http://techmikael.blogspot.com/
    Author of Working with FAST Search Server 2010 for SharePoint

    • Proposed as answer by heblisumanth Tuesday, June 25, 2013 10:49 AM
    Tuesday, June 25, 2013 8:24 AM
  • Thanks a lot Mikael.
    Tuesday, June 25, 2013 10:51 AM
  • Hi Afzal,

    I know it late to tell you about a wonderful tool that you might want to use for creation of your FQL queries and for testing purpose. It's a free tool. you can download it from below mentioned url

    http://fastforsharepoint.codeplex.com/

    I have used this tool in one of my project. It's really easy and helpful

    I hope this is helpful for you. If this works, Please mark it as Answered.

    Regards,

    Dharmendra Singh (MCPD-EA | MCTS)

    Blog : http://sharepoint-community.net/profile/DharmendraSingh

    Saturday, September 27, 2014 5:04 AM