SharePoint 2010 Search: The Good News and the Bad News

29. January 2010

Microsoft SharePoint Server 2010 is just around the corner now and it will once again raise the bar in the SharePoint Enterprise Search space. I witnessed the new SP2010 search experience first time at the SharePoint 2009 conference in Vegas last year and was overall quite pleased with what I saw there. It looks like the search team in Redmond has really listened to the community and their customers and addressed many of the annoying pain points present in the SharePoint Server 2007 search experience.

However, having worked with SP2010 Beta 2 for a while now has revealed some pain points / annoyances left behind in the product. Some of them I can understand from a technical standpoint while others just make we wonder how they could miss it again. Don’t get me wrong here – I’m still a big fan of SharePoint Search and just want this part of the product to be mere perfect. Seriously, Enterprise search is an ever more vital part of most SharePoint deployments.

Anyway, I am dedicating this post to sharing the good news and the bad news I have learned so far by working with SharePoint Server 2010 Search. Please note that the FAST Search Server for SharePoint 2010 is not included in my evaluation here – it is technically and financially a whole other ball game.

The Good News

  • Improved relevance. More parameters included in score calculation. One cool new parameter is click-through rate on search results also known as popularity ranking. Other parameters include URL fuzzy matching, social tags, inferred metadata, detected language and implicit phrase matching.
  • Enhanced query syntax. Enables power users to build advanced queries using Boolean operators like AND, OR, NOT. Also support for the range operators <, >, <=, and >= for searching numeric ranges or date ranges.
  • Wildcard search. Now possible to search for partial words using the wildcard character *. For example search for: Micro* author:bill*
  • Enhanced multi-lingual support. Improved language detection from document text, better word breaker in more languages for better handling of compound words.
  • Phonetic and nickname search. Useful in people search to match similar names with different spelling. E.g. a search for Chris also returns people named Kris or Christopher. I really like this new feature as it makes people search much more precise and useful.
  • Faceted search aka. Refiners. Presents users with a list of relevant suggestions for refining the search results by document type, site, author, modified date, tags or any other managed property available in the index. The refiners as Microsoft like to call them, offers a very simple and intuitive way to filter results by metadata.
  • Query suggestions. Presents a list of relevant search terms as you type – this is known as pre-query suggestions. There is also post-query suggestions, which is just a Web part listing related queries. The suggestions are based on past queries from other users.
  • Improved did you mean suggestions? Support for more languages.
  • View in browser. Link in the search results for viewing office documents with full fidelity directly in the browser. Requires Office Web Applications 2010 to be installed on the server. This feature is very useful to users who do not have the Office clients installed or do not want to always download the entire document.
  • Open Web Parts. The OOB search Web parts are no longer sealed! Consequently, it will be much easier for developers to build their own custom search Web parts simply by extending the built-in ones. With SharePoint 2007 you would have to build your own from scratch, which is a very daunting task.
  • New Connector Framework. This is the next evolutionary step of the Business Data Catalog introduced in SharePoint Server 2007. Indexing external content has become a lot easier thanks to much better tool support in the form of the new SharePoint Designer 2010. Hooking up SharePoint to index content from a database is now a no-brainer; point SPD to your database to automatically reverse engineer a BDC model, then deploy that model to the indexer via the admin UI. To index more complex and dynamic repositories, developers can now also build custom connectors in managed code (The old C++ Protocol Handler API is still supported). Other great improvements over the old BDC are the ability to index document attachments and item security (ACLs).
  • Improved admin dashboard. Offers a few improvements to the search admin dashboard introduced in SharePoint 2007 with the infrastructure update.
  • New health analysis tool. Can generate reports useful for performance monitoring, capacity planning and troubleshooting.
  • PowerShell scripting. Enables administrator to automate virtually all search administration tasks by using Windows PowerShell 2.0 scripts.
  • New and improved deployment architecture. The search system has been componentized a lot more for improved performance, scalability and availability. With enough servers, SharePoint Search now scales to about 100 million documents while maintain fresh indexes and sub-second query latency. The most welcome improvement is without doubt support for multiple stateless crawlers (aka. indexers) on the same content source. Another biggie is support for partial indexes, i.e. support for splitting a large index across multiple query servers.
  • Better support for indexing case sensitive repositories.
  • Improved Search Analytics. SP2010 more or less includes the same type of search analytics reports as we know from SharePoint Server 2007. But they have received some nice improvements like nicer graphics and the ability to view data in any date range. Also, it is now possible to create custom reports thanks to a new and documented Data Warehouse.
  • Desktop search integration in Windows 7.

The Bad News

  • The same old advanced search Web part. Looks like it was brought over from SharePoint 2007 as is - it still does not offer a good parametric search experience with property value drop-downs and the like. Users will still need to know and type possible metadata values. However, with the introduction of faceted search this shortcoming is not as severe as it was for SharePoint Server 2007 when it came out. Furthermore, the enhanced query syntax will also make it a hell lot easier for developers to create their own advanced search Web part to assist users in constructing complex queries.
  • Sub-optimal navigation experience. If search is great, users will adopt it as a good navigation tool. But in a SP2010 search center there is no way of navigating from a document search result to the document library where the document lives. Also, it can be hard for users to navigate back from the search center to the site they initiated the search from. However, these issues can be fixed with a little customization. But it would have been nice to see a greater user experience out-of-the-box.
  • Inconsistent search UI. The problem I am referring to here is that searching the "This site" search scope in the search box does not take the user to a search center; instead it takes her to the SP2010 Foundation search page in the _layouts folder. All other search scopes take her to the full search center. In other words you still have two different search interfaces in SharePoint. My recommendation will be to turn off the “This site” scope as results can anyway be refined by Site in the search center.
  • No Visual Best Bets. I have heard Microsoft presenters get all exaggerated about the Visual Best Bet feature available with FAST search. But it is really nothing special – just a Best Bet with an image! Seriously, this feature should also be available with the built-in search engine. In other words, the Best Bets feature does not seem to have received any improvements from SharePoint 2007 whatsoever.
  • Changes to managed properties still require a full crawl. Managed metadata properties are still there and managed exactly the same way as in SharePoint 2007. This is also good - but there is still one major annoyance that I had hoped MS would find a solution for. Adding a new managed property or changing an existing one, requires a new full crawl. This should not be necessary as the metadata is already indexed and searchable via a crawled property.
  • No push based indexing. It is not possible to notify the search index about immediate/important changes to content. The index will still have to wait for the crawler to stop by and pick up the changes for the index.
  • Incomplete indexing of system metadata. The indexer does not pick up all system metadata on documents. Forget about finding crawled properties for document information like CheckOutStatus, CheckedOutBy and CheckedOutDate. Then there is the ContentTypeId, which is indexed – but it seems to only happen for Office documents in the new 2007 format. A properly indexed ContentTypeId would make hierarchical searching on content types possible.
  • No document preview with hit-highlighting. This feature is unfortunately only available for FAST Search and here it does not even look very convincing except for PowerPoint documents.

Fortunately the list of bad news is shorter than it was for SharePoint Server 2007 back then. But let us see if we identify more good/bad news as we get to learn SharePoint 2010 Search better. I would love to hear from you out there – have you found other good or bad news on the topic?

SharePoint Search , ,

Implementing Actionable Search Results with Microsoft Office SharePoint Server 2007

17. June 2009

This article will show you how to customize the search results in a MOSS 2007 search center to add some useful action links to document results. This is a solution that I have had in the drawer for some time and recently I dusted it off for use in Webinars on Turning SharePoint Search into a better Navigation tool. The interest for getting the actual code has been overwhelming and I decided I better blog it now.

Out-of-the-box, SharePoint basically offers only one action on results; a link for opening a document in read-only mode. This is fine for Internet/Extranet scenarios where there are few documents and where users are not supposed to edit them. But for an Intranet collaboration portal the picture is different. Here users may work on many documents on multiple sites and in multiples document libraries. Not knowing or forgetting exactly where a document is stored or just not wanting to tediously browse their way down to a specific document is a fair and common story. This is where SharePoint search can help – just type one or more relevant keywords, click the search button and open the document without worrying too much on which site and in which document library it is stored. A typical document result in a default search center looks like this:

ActionableSearchResults1

But what if users want to perform additional actions on the document like check-in, check-out, view properties, etc? Ouch! No way to navigate to the document library where the document lives! Fortunately, SharePoint is a very flexible platform and the SharePoint search results can with fairly little effort be customized to include a link for navigating to the document library. While we are at it, why not also add a few more useful actions? The code sample that I am about to share below adds four actions to document results as illustrated below:

ActionableSearchResults2

Then Send link action opens a new email with a link to the document, Add to My Links opens a dialog where users can add the result to their My Links list, View properties redirects to the properties page of the document library list item from where the containing document library folder can also be accessed. Finally Edit document opens the document for editing and asks for check-out if required. The fifth View duplicates action is available OOB as illustrated in the first screen shot.

The sample implementation that you can download below is composed of two parts; a custom XSLT template for the Core Results Web Part plus an ASHX handler for the View Properties action. Let us first have a look at how the custom XSLT template implements each custom action link. The following table shows the HTML and Javascript code used in the template. Please consult the downloadable zip archive below or the link above for the full XSLT listing.

Action URL
Send link
<a href=”javascript:SendEmailWithLink(‘[url]’)”>Send link</a>

where [url] is the full path to the result item. The Javascript method SendEmailWithLink is implemented as follows:

function SendEmailWithLink(link) 
{ 
  var link = "mailto:?body=" + escapeProperly(link); 
  navigateMailToLink(link); 
  return false; 
}
Add to My Links
<a href=”javascript:AddToMyLink(‘[title]’,‘[url]’)”>Add to My Links</a>

where [title] is the item title and [url] is the full path to the item. The Javascript method AddToMyLink is implemented as follows:

function AddToMyLink(title, url) 
{
  var args = new Array();
  args[0] = title;
  args[1] = url;
  args[2] = '';
  var features = 'resizable=no,status=no,scrollbars=yes,'+
                 'menubar=no,directories=no,'+
                 'location=no,'+
                 'width=750,height=475';
  if (browseris.ie55up)
    features = 'resizable:no;status:no;scroll:yes;'+
               'help: no;center: yes;'+
               'dialogWidth:750px;dialogHeight:475px;';
  commonShowModalDialog(
    '/_layouts/QuickLinksDialog.aspx',features,null,args);
}
View properties
<a href=”/_layouts/actionredirect.ashx?url=[url]”>View properties</a>
Edit document
<a href="" onclick=”
  return editDocumentWithProgID2('[url]', '', 
                                 'SharePoint.OpenDocuments', 
                                 true, '', false)”>
Edit document
</a>

where [url] is the full path to the result item. The Javascript method editDocumentWithProgID2 is supplied by SharePoint.

The View Properties action can unfortunately not be implemented as easily as the other actions. It requires an extra layer of indirection as the search content index cannot give us the list item ID of documents in a document library. But we need this to redirect to the View Properties page having an URL of the form:

http://server/Docs/Documents/Forms/DispForm.aspx?ID=4

 

To construct and redirect users to this URL, the View Properties action simply redirects to a custom ASHX handler with the full document URL as a parameter. The handler will in turn lookup the document list item using the SharePoint object model. Once the list item is found, the final redirect URL is created and applied. This happens very fast server side and the user will never notice the extra redirection.

Installing the sample goes like this:

  1. Download and unzip the complete sample.
  2. From the unzipped folder, open the file ActionableSearchResults.xsl in Visual Studio, SharePoint Designer or any other text editor.
  3. Copy and paste the XSLT code from the file to the XSLT editor on the Core Results Web Part. For more information see customizing search results with custom XSLTs in SharePoint Server 2007.
  4. From the sub folder SharePoint Action Redirect, run the script install.cmd to deploy the sharepointredirect.wsp solution to your SharePoint farm.
  5. Done.

Disclaimer: The sample code is provided as-is and you are free to modify it anyway you see fit.

SharePoint Search ,

Repost: The secrets of SQL Syntax Queries for Relevant Results in MOSS 2007 Enterprise Search

31. March 2009

This is a repost of an article on my old Mondosoft blog, which is not live anymore. For some time I thought the article had been lost forever as I did not have a local copy of it. But fortunately some other bloggers had copied the entire content to their own blog, which enabled me to recover it and now post it again.

This post is a tutorial on using the Microsoft.Office.Server.Search.Query.FullTextSqlQuery class for searching with the MOSS 2007 search engine with the Enterprise Search SQL syntax. I will at the end of this posting explain how to execute queries for optimal results rankings. But let me first establish the basics of using the FullTextSqlQuery class. You will only need to employ it for one of the following reasons:

  • You need to support Wildcard searches.
  • You need to search with date ranges.
  • You need to search properties with different operators (CONTAINS, =, >=, <=, <, >, LIKE).
  • You need to search properties for NULL values.
  • You need to use the NEAR operator.
  • You need nested Boolean queries.
  • You like the most flexible (or complicated ;-) ) solution.

 

Simple keyword and property queries are easier done with the Microsoft.Office.Server.Search.Query.KeywordQuery class. I will, however, not cover this class here. Ok, let us get started. I have outlined the format of the SQL Syntax accepted by the MOSS 2007 search engine below. After that I will show how to talk to the search engine via the official .NET API.

 

SQL Syntax

A SQL query is a string that must adhere to the following structure:

SELECT <columns>
FROM <content source>
WHERE <conditions>
ORDER BY <columns>

 

SQL Syntax Examples

Finds relevant results containing the keyword SharePoint.

SELECT WorkId,Path,Title,Write,Author,HitHighlightedSummary,
HitHighlightedProperties,CollapsingStatus
FROM Scope()
WHERE FREETEXT(defaultproperties, 'SharePoint')
ORDER BY Rank Desc

Finds relevant results containing at least one of the keywords SharePoint and Search.

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, 'SharePoint Search')
ORDER BY Rank Desc

Finds relevant results containing both the keywords SharePoint and Search.

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, '+SharePoint +Search')
ORDER BY Rank Desc

Finds relevant results containing the exact phrase SharePoint Search.

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, ' "SharePoint Search" ')
ORDER BY Rank Desc

Finds relevant results containing both the keywords SharePoint and Search but not the keyword WSS

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, '+SharePoint +Search -WSS')
ORDER BY Rank Desc

Finds relevant SharePoint results authored by persons named John.

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, 'SharePoint') AND CONTAINS(Author,' "John" ')
ORDER BY Rank Desc

Finds relevant SharePoint results modified within the last 30 days.

SELECT WorkId,Path,Title,Write,Author,...
FROM Scope()
WHERE FREETEXT(defaultproperties, 'SharePoint')
AND Write<=DATEADD(DAY,30,GETGMTDATE())
ORDER BY Rank Desc

 

.NET API

The following code should give you some inspiration how to execute a SQL query against the MOSS 2007 search engine.

// Execute Query
ResultTableCollection results = null;
using (FullTextSqlQuery query = new FullTextSqlQuery(ServerContext.Current))
{
query.StartRow = 0;
query.RowLimit = 10;
query.HighlightedSentenceCount = 3;
query.EnableStemming = true;
query.TrimDuplicates = true;
query.Culture = CultureInfo.CurrentCulture;

query.KeywordInclusion = KeywordInclusion.AnyKeyword;
query.SiteContext = new Uri("http://yourserver/sites/asite");
if (SPSecurity.AuthenticationMode != AuthenticationMode.Windows)
query.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
else
    query.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;
query.QueryText = "SELECT ... FROM Scope() WHERE ... ORDER BY ...";
results = query.Execute();
}


// Parse results and create XML output
StringBuilder buffer = new StringBuilder(10240);
ResultTable relevantResults = results[ResultType.RelevantResults];
using (XmlTextWriter writer = new XmlTextWriter(new StringWriter(buffer)))
{
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("Results");
writer.WriteAttributeString("hits", relevantResults.TotalRows.ToString());
while (relevantResults.Read())
{
writer.WriteStartElement("Result");
for (int i=0; i<relevantResults.FieldCount; i++)
{
writer.WriteStartElement(relevantResults.GetName(i));
object val = relevantResults.GetValue(i);
if (val != null)
writer.WriteString(val.ToString());
else
writer.WriteString("null");
writer.WriteEndElement();
}     
writer.WriteEndElement();
}
  writer.WriteEndElement(); string xml = buffer.ToString();
...
}

The using statement around the usage scope of the FullTextSqlQuery class is very important to remember as you will otherwise get an OutOfMemoryException after running a good number of queries. This is so because the search engine is a COM server that the .NET API maintains a handle to.

 

A closer look at the FREETEXT predicate

Take a look at following two keyword searches using the FREETEXT predicate (rest of SQL string omitted for simplicity):

FREETEXT(defaultproperties, '+sharepoint +search')
FREETEXT(defaultproperties, 'sharepoint') AND FREETEXT(defaultproperties, 'search')

Both queries are valid and yield the same results buth with different ranking. Which one yields the best results ranking? Answer: The first one! It is recommended that you only use one FREETEXT predicate in a search query. Results ranking will otherwise not be optimal.

The defaultproperties keywords references the default set of properties to include in the ranking algorithm. This is also recommended for optimal ranking of results. You can alternatively use the WITH predicate to define your own set of properties if you are not happy with the default one. This is helpful if you need to promote results containing the keywords on your own custom properties. Note: The standard MOSS 2007 search center simply uses the defaultproperties.

The FREETEXT predicate can also be configured for implicit AND search or implicit OR search. This means that a query like:

FREETEXT(defaultproperties, 'sharepoint search')

can respectively find results containing both the keywords sharepoint and search or find results containing at least one of the keywords. Use the the KeywordInclusion property on the FulltextSqlQuery object to control this behavior. See the code example earlier in this posting.

 

Conclusion

I have just described the key concepts of using the FulltextSqlQuery class. I have not described all of its features nor have I described the SQL Syntax in full. I refer you to the MOSS 2007 SDK for a complete reference.

SharePoint 2007, SharePoint Development, SharePoint Search , ,

BA-Insight going strong with SharePoint Search

5. February 2009

It is in these times of crisis great to hear about a SharePoint ISV that manage to defy the negative trends in the market. BA-Insight are according to my contacts there experiencing good growth with their product Longitude that greatly enhances the SharePoint search experience. My favorite features in the product are the Document Preview, Faceted Search and the Search Connector Framework that provides strong connectivity to Line of Business systems. They have also recently introduced strong support for parametric search. See the complete list of features here.

I know the guys (and girls) at BA and can strongly recommend their product. One of my clients here in Denmark recently purchased the product and will in fact go live with it in the weekend to come. I am sure this will be a success story as there has been an internal preview the last couple of weeks for selected users. The feedback has been very positive so far.

They provide very good support and their pricing is also very reasonable. You should really do yourself a favor and watch their demo videos if you are only using standard SharePoint Search today.

SharePoint Search ,