You can administer keywords and best bets on the MOSS admin UI at Search keywords at Site Collection Administration.
Stefan Goáner gave a code snippet about How To: create Keywords and Best Bets for MOSS Search programmatically. A similar code can be found in the very useful SharePoint Server 2007 Presentations: Enterprise Search Deep Dives presentation series, Customizing and Extending Search in Office SharePoint Server 2007.
Based on my experiments there might be a little but important problem with this code. When creating the new Keyword instance, you should use DateTime.UtcNow instead of DateTime.Now to enable the Keyword immediately:
keywords.AllKeywords.Create("myKeyword", DateTime.UtcNow);
When you create the keyword through the UI, you can specify only the date part, no hours and minutes. In this case the keyword is created with a start date (StartDate property) 0:00 AM UTC for the specified date. For example, currently our local time is GMT+1, so the start date would be 23:00 PM for the previous day.
When I used the code samples “as is”, the keywords were not displayed in the results. After one hour, the repeated search already displayed the keyword matches. When I used the DateTime.UtcNow, the results were displayed immediately. Of course, if your configured time zone is west from the GMT time line, then DateTime.Now should work also, as it is refers to a time in the past if you interpret it as UTC time.
If you try to create a best bet on the UI that refers to an URL already used in an existing best bet you cannot save the new best bet. I found another interesting behaviour of creating keywords and best bets from code. The code that creates the best bets with a common URL but different titles and descriptions will run without errors:
Keyword keyword1= keywords.AllKeywords.Create("keyword1", DateTime.UtcNow);
BestBet bestBet1 = keyword1.BestBets.Create("BestBet1", "Description1", new Uri(http://www.company.com));
keyword1.Update();
Keyword keyword2= keywords.AllKeywords.Create("keyword2", DateTime.UtcNow);
BestBet bestBet1 = keyword2.BestBets.Create("BestBet2", "Description2", new Uri(http://www.company.com));
keyword2.Update();
3 comments:
Hi Anand,
Is it possible to create 2 level approvals/ Content Approval for any custom list in MOSS 2007
Regards
Iranna Shettar
(imshettar.at.gmail.dot.com)
Hi Iranna,
Yes you can have multiple levels of content approval. However, a custom content approval workflow would have to be in place to achieve this. OOTB, I believe, one level is possible.
Rgds,
Anand
Thanks, Let me check get back to you.
Thanks
Iranna Shettar
Post a Comment