Wednesday, 9 September 2009

Problem adding Keywords and Best Bets programmatically in MOSS 2007

I was writing a small Windows application for a customer to create keywords and best bets using a CSV file and experienced a weird problem. I used the code published here by Stefan Goßner as a starting point, which successfully added the keywords to the Manage Keywords UI in Site Collection Administration, but when I tried to search on one of the keywords, no best bets were shown in the search results.

The format of the CSV file was, as follows:

Keyword name, Synonyms (semi-colon delimited), Best bet URL

For example: Acme Primary School, Acme;Acme School;Acme Primary,

The code I used to create the keywords was:

keywords.AllKeywords.Create(keywordTerm, DateTime.Today.AddHours(-1));
keywords.AllKeywords[keywordTerm].BestBets.Create(objBestBet.ToString() + " Profile", "Full school profile for " + objBestBet.ToString(), new Uri(objUrl.ToString()));

I then found that if I clicked on one of these keywords in the Manage Keywords UI and clicked OK without changing anything, the search for that keyword worked. I eventually discovered that SharePoint didn’t like adding the semi-colon delimited synonyms as a single string and that they needed to be created separately. Therefore, I changed the code to below, using the semi-colons to split the string up into an array of separate synonyms, which worked:

keywords.AllKeywords.Create(keywordTerm, DateTime.Today.AddHours(-1));
//Create synonyms from semi-colon separated array
string[] synonymArray = objSynonyms.ToString().Split(new char[] { ';' });
foreach (string synonym in synonymArray)
keywords.AllKeywords[keywordTerm].BestBets.Create(objBestBet.ToString() + " Profile", "Full school profile for " + objBestBet.ToString(), new Uri(objUrl.ToString()));


  1. Hi Phil,

    I too face the same problem.
    I have added only Keyword, definition & best bet but still i am not getting keyword in search.
    then if i simply edit the keyword in UI & then clickin OK, now keyword is displayed in serach.

    Kindly let me know how to solve this issue bcoz u have mentioned that u have seperated Synonyms by semicolon";" but i havn't added

  2. Hi,

    Have you updated your keywords after the changes (see last line in my code above)? The problem I was having was with synonyms, so if you haven't got any then it is probably a different issue to the one I had.


  3. Can you post a "step-by-step" for doing this with a CSV for SharePoint / FAST 2010? I'm starting to loose all my hair on this ;) Any help would be greatly appreciated.


  4. Hi Bryan - I have posted a reply to this on my PowerShell blog at


  5. || || || n || || || || n ||

  6. If you have a history of illness that is difficult to recover, maybe our next article will help you to recover

    Obat Untuk kaligata
    Obat Untuk Menghilangkan keputihan
    Obat Pengering luka bernanah
    Obat luka
    Obat eksim

  7. Due to sending in those offer, You are investing in buy this realisation brand from the vendor if you're the earning prospective buyer. You read and sign the worldwide transportation structure affiliate agreement unwraps in any pickup's wind shield also known as loss. Transfer costs by now quotation probably have become controlled by change if you ever speed up you uttermost place a bet little..

    If the house is Camisetas De Futbol Baratas always went back following a established time it Maglie Poco Prezzo will undergo a 20% re selling commission rate aka refusal. For Coach Outlet Online Store something to qualify for head back or replace, The system had to be inside one of a kind overall disease utilizing manuel neuer trikot rot the labels it maillot de foot personnalise entered. hummel trikots In cases where the taken back service supplying is divided or is devoid of you should we will resultados de futbol see a Restocking charge all the way to 20%.

    By - applying your personal quote, You are investing maillot de foot pas cher in buy here food from the owner if you are the succeeding prospective buyer. You read maillot foot 2018 and accept the world shipping and delivery company conditions starts advertising in a meaningful door and bill. Significance allegations earlier amazon müller trikot in this article cited have been controlled by change inside event you improve you greatest tender value.