Recap
Search scopes improve the SharePoint search experience by letting users search over a subset of information within an organisation. For example you can create a search scope for a specific project or a group such as Legal or Marketing. Search scopes can either be created globally at the search service application level so they are available to all site collections, or defined within a specific site collection.
Creating search scopes
Global search scopes in SharePoint 2010 can easily be created using PowerShell commands such as New-SPEnterpriseSearchQueryScope. Corey Roth covers this in his article on Creating Enterprise Search Scopes with PowerShell. While the PowerShell method can also be used to create site collection related search scopes you might also want to do this programmatically in a feature receiver. Another thing you might want to do programmatically is to associate a search scope with a display group such as the ‘Search Dropdown’ so it appears in options next to the search box.
As there are problems with some of the methods that can be used to create search scopes and display groups programmatically I’ll detail these in this article. In a follow up article I’ll cover a method of creating scopes and scope display groups that avoids these problems.
The object model classes I will cover in this article are:
- SearchContext
- SearchServiceApplication
- SearchServiceApplicationProxy
SearchContext
This is only included as it is referenced in other articles and was a common way to create scopes in SharePoint 2007 such as in the code shown below.
In SharePoint 2010 this class is marked as obsolete and should not be used. If you use the SearchContext class in your code you will get the following warning at compile time:
“This class is obsolete now. Please use SearchServiceApplication and SearchServiceApplicationProxy instead.”
According to the article Microsoft SharePoint Server 2010: Deprecated Types and Methods:
Obsolete types and methods will continue to work in your custom code and solutions, but they will generate compiler warnings, and you should update your code to use the new types and methods as indicated by the compiler warnings.
So while this might work it may not always function as expected and there is no guarantee it will continue to work in the future. Next we will look at the alternatives suggested in the compiler warning message.
SearchServiceApplication
If you are updating SharePoint 2007 code the SearchServiceApplication class is an obvious choice as it is a suggested alternative to the SearchContext class. The code is slightly more complicated as you need to retrieve various classes relating to the search service application but a similar outcome can be achieved using the code below:
There is a fundamental problem with this code, however (on top of the hardcoded strings and a complete lack of error handling). The code tries to access the search service application database directly without going through the search web service. In a least privilege installation this means that the application pool account of the web application containing the site collection will be used (even if you elevate privileges for this code) and will not have access to the search service application database by default (as least privilege requires separate accounts for search and content). The specific error message you get when running this code is:
System.Data.SqlClient.SqlException: Cannot open database “Search_Service_Application_DB_{…}” requested by the login. The login failed. Login failed for user ‘{0}’. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
In the example above DEVDOMAIN\spcontent is the identity of the application pool of a web application that contains the content sites for which I want to create search scopes. Using the code above the spcontent account is trying to access the database directly as shown below:
This is something to watch out for as if your dev machines are not running a least privilege installation but your production servers are the issue may not manifest itself until it is difficult and costly to fix.
What we need to do is go through the web services so the account running the search web service (in this case an account named DEVDOMAIN\spservices) is used to connect to the database as shown below:
In the screen shot the intuitively named a168dee… application is the search web service.
This brings us on to the next method mentioned as an alternative to the SearchContext class – the SearchServiceApplicationProxy class.
SearchServiceApplicationProxy
This class requires the use of ScopeInfo and DisplayGroupInfo objects and requires some lower level code such as passing around the ID’s of the display groups. This does get around the database access issue metioned above, however, as it goes through the SearchServiceApplicationProxy class which uses the search web service instance.
While this method works, it requires a lot more code than the methods above and isn’t as intuitive. What used to take 9 lines of code in SharePoint 2007 now takes 30 lines and requires us to pass round the Id’s of scopes and display groups and managing the list of display groups in our code.
So to summarise we have found that:
- SearchContext is now obsolete (and can also cause permission issues)
- SearchServiceApplication can lead to permission issues if called from within a feature receiver as it doesn’t use the search web service
- SearchServiceApplicationProxy uses the search web service but requires much more code and is difficult to work with
6d3ea7d6-6c8c-4ccd-85bc-974181fe1f09|0|.0
Findability is one of the most important factors in the success of a SharePoint site. If users cannot find what they are looking they will quickly use alternate methods to get results. Employees that cannot find information are less productive and less likely to use the system in general. Likewise users that cannot find information on an internet site will look elsewhere for products and services losing the company revenue.
SharePoint 2007 introduced some powerful tools for improving findability but fell short when it compared to larger Enterprise Content Management systems. SharePoint 2010 takes this a huge step forward with cutting edge enterprise ready findability features. Here are 10 new features SharePoint 2010 brings to the table in addition to the features available in SharePoint 2007.
1. Metadata driven navigation
SharePoint 2010 provides a rich set of features that allow users to use metadata to navigate content repositories. Document libraries can be configured to show navigation based on both the corporate taxonomy (or managed metadata) and combined with other metadata filters. For example with a you can filter items from the ‘Bicycle’ product category of content type ‘Sales presentation’ using the navigation as shown below.
2. Search enhancements
SharePoint 2010 includes some impressive enhancements to the search experience. Search facets allow users to filter the results by relevant metadata such as author or content type. Relevancy is improved as it takes the number of views into account. This, along with the addition of related queries, improved query syntax and thumbnail previews help users locate the content they are after.
3. Ratings
The introduction of a ratings field allows community driven content classification. Ratings can be used to improve findability through sortable list columns, or by the creation of ‘highest rated documents’ rollups using the Content Query Web Part, allowing users to see popular content in prominent places.
4. Tagging
SharePoint 2010 includes a tag cloud web part that provides a visual representation of the metadata associated with the content inside a repository. Additionally tag profile pages contain lists of items such as sites, documents or people tagged with a particular term as well as a list of community members and discussions facilitating information retrieval.
5. Document IDs
SharePoint 2010 provides a unique Document ID service that can be used to create absolute references to content regardless of file renames or content moves. As well as resulting in a reduction in broken links the Document ID can be used to search for an individual document and the format of the ID is configurable allowing organisations to create meaningful document identifiers.
Classification
All the findability improvements mentioned above rely on the correct classification of content in the first place. The following five findability improvements aid the correct classification and organisation of content in SharePoint 2010.
6. Managed metadata service
SharePoint 2010 now includes a dedicated service for managing metadata within the enterprise. The managed metadata service allows content owners to maintain a centrally managed structured taxonomy as well as allowing users to contribute to an unstructured ‘folksonomy’ in the form of managed keywords. This makes it much easier for users to classify content, and guides users to use consistent terms, improving the quality of metadata in the system.
Structured classification:
Unstructured classification:
7. Shared content types
One key architectural limitation in SharePoint 2007 was that Content Types could not be shared between site collections. This resulted in the duplication of content types and associated lookup lists which could become out of sync over time. SharePoint 2010 removes this limitation and thus improves the consistency of information stored in different site collections or even separate SharePoint farms.
8. Location based metadata defaults
SharePoint 2010 allows you to set metadata defaults at the document library and folder level. This means that users do not have to enter the same metadata over and over if they are uploading content into a repository that has a shared set of metadata.
9. Content Organiser
In SharePoint 2007 the location in which content was stored was largely up to the end users. The Content Organiser in SharePoint 2010 helps alleviate problems caused by users uploading documents to a variety of different places by allowing routing decisions to be centrally managed. Content can then be routed to the correct location based on the content type and other metadata values. This helps the user to focus on providing quality metadata and results in a well organised repository.
10. Document Sets
A document set allows you to manage a group of documents as a single entity. The ability to apply metadata to the entire set of documents improves consistency and storing related documents together can help users find relevant material easily.
Summary
SharePoint 2010 delivers some massive platform improvements that help in the classification and retrieval of content. It is important to note, however, that the toolset is only a small part of an information management strategy. Information management should start with clear business objectives, a clear strategy and right areas of focus before technology is involved. Once this is in place, however, the significant advancements of SharePoint 2010 make it a more obvious choice for content management than ever before
6b09d2d8-0ba7-4071-bc05-bb26686ba76e|0|.0