Sunday, November 20, 2011

Taking promotions/demotions one step further in FAST Search for SharePoint

promotionsI am not sure how many times I have read the documentation on promotions and demotions in Microsoft documentation, but I can say it is numerous.

And yet yesterday I discovered a valuable piece of nugget which I’m sure I will use a lot in the future.

Up until yesterday this was my complete understanding of promotions and demotions in FAST for SharePoint.

You can promote and demote items based on it’s url. Via SharePoint admin UI the boost is absolute by adding 1,000,000 rank points, effectively pushing the item to top of the result list.

If using the SharePoint UI you have to add the promotions to a keyword, but when using PowerShell you can make a “global” promotion which affects all search queries.

You can promote and demote sites based on the start of a url. For example promoting “http://site/” via SharePoint admin UI will give all items which has a url starting with “http://site/” 1,000 extra rank points. A soft boost.

Using PowerShell to create promotions and demotions lets you specify the boost value yourself.

Each of the promotions can be associated with a user context in order to target the promotion to specific users, and you can set a start and end date for the promotion.

There is MORE!

This is all good, but there is more. Doing some PowerShell scripts around promotions I stumbled upon the very little documented function AddPromotedExpression. If you google this function you will get two hits, both on MSDN with the very sparse documentation text

“Creates a promoted expression and adds it to the collection.”

with the function signature:

PromotedExpression AddPromotedExpression(
    string fqlExpression

What this means is we can write an arbitrary FQL expression for promoting or demoting items. Let’s say we want to demote all items which are larger than 3MB and located on a file server. The following fql will match the criteria:


Executing the following lines in a FS4SP PowerShell will add the demotion:

$searchSettingGroup = Get-FASTSearchSearchSettingGroup
$globalPromotions = $searchSettingGroup.PromotionsWithoutKeyword
$globalPromotion = $globalPromotions.AddPromotion("FQL size and file") 
$globalPromotion.BoostValue = "-4000"
$fql = 'and(size:range(int("3145728"),max,from="gt",to="le"),url:starts-with("file://"))'

Hope this will come in handy!


  1. Very useful. Thanks for sharing!

  2. Hi,

    Could we link this to a specific User Context?



    1. Hi again,

      I've seen how to do that with:
      $userContexts = ({prueba})

      Sorry for the inconveniences.


  3. Hi Mikael. This MSDN article says that

    "When using FQL as the query language, you cannot use the FAST Search Server 2010 for SharePoint keyword management features (such as promotions or demotions). If you use FQL only in search scope definitions, this limitation does not apply."

    Do you happen to know if that applies to promoted expressions?


    1. Hi,
      using FQL in your queries will not match keywords as keywords are matched to the query string. So as long as you use normal keyword queries from the end-user then promotions will trigger. And using FQL as the promotion expression will work just fine. It has nothing to do with the actual query itself. Think of it as adding a scope. Query building wise on the FAST side it acts much the same way.

      1. User Query
      -> Match Keyword
      2. Query is rewritten to FQL
      3. Scopes are added to the FQL query
      4. Promotion queries are added to the query

      PS! The above order is conceptually how it works as I haven't checked the exact sequence :)

      PS2! It might work to add a keyword term like this:
      string("query", mode="simpleall")

      And if you pass in the same FQL in your query it should in theory hit, but I haven't tried this.


    2. Hmmm - I may have to prove this out to understand the nuances.

      For example, sounds like if I set up a .NET app that calls my FS4SP backend and submits FQL queries it would not apply a document promotion that is associated with a keyword. But what if I applied my doc promotion as a global promotion (not associated with a keyword). Does that work?

      Likewise with promoted expressions.

      Ultimately what I want to do is apply some XRANK expressions that apply both in my search centers (KQL queries submitted from OTB web parts) *AND* to external apps that utilize the search engine. Sounds like this will work with a scope but not sure about a promoted expression.

  4. Hi,

    Currently using FQL to set relevancy. However, we are running into long query times. Wondering if promoted expressions/FQL are playing a part in the query latency. Also curious if it is possible to apply FQL during crawl time instead, to avoid all the calculations involved if FQL was applied at query time.

    Thank you.

    1. Hi,
      Using xrank in fql can quite possibly impact query times if a lot of results are returned.

      Depending on what you want to accomplish you can look into the static rank components of a rank profile. I cover this somewhat in Chapter 6 and 10 of my book :)