Wednesday, October 3, 2012

Wednesday, February 1, 2012

SharePoint Contextual Search Scopes

SharePoint provides two categories of search scopes: Custom and Contextual.
·    Custom scopes:
o  "All Sites"
o  "People"
o  The custom search scopes created via the search or site admin pages
·    Contextual scopes:
o  “This Site”
o  “This List”

Search behaves a little differently between these categories. Specifically, there are two pages on which search results are displayed, one for each category. The page for Custom scope results is the most familiar: it’s the one that offers custom scopes and properties available via Advanced Search.  The page for Contextual scope results is much simpler: there are no best bets, high confidence results, advanced search link and search tabs, and it can’t be customized in browser since it’s not a web part page.

Also, the search results page that can be configured on the Search Settings page affects Custom scope results, and is set to “/sites/fastsearch/Pages” in our environment.  This setting has no effect on Contextual scope results, which always go to /_layouts/osssearchresults.aspx for SharePoint Enterprise/Standard installations (for SharePoint Foundation, it is /_layouts/searchresults.aspx).
Our custom master pages (meijersearch.master and meijer.master) don’t really work well with search results (loading freeze of office web application thumbnails), and We turned meijersearch.master off in Fast Search Center during the upgrade. We cannot do the same to make /_layouts/osssearchresults.aspx work, since it inherits master page from its Context.

I found out OSSSearchResults.aspx and /sites/fastsearch/Pages/Results.aspx return the same results with same search parameters (following URLs can bring back same results). One of viable solutions could be redirecting all contextual scope searches to our Fast Search Center content result page(/sites/fastsearch/Pages/Results.aspx).





Tuesday, January 31, 2012

My Understanding of SharePoint List View Threshold

In SharePoint 2010, administrators can configure resource threshold on list view for each web application. The default value is set to 5000, which means a list view can't return more than 5000 items.

Many online posts, including this excellent technet article, have told the story of resource throttling for large list in depth. Here I just want to share my reader's digest version.

Why 5000? Why not 8000? Well, it turns out this threshold has not much to do with SharePoint itself, rather it is actually coming from SQL Server.

In SQL Server, a list item essentially is a row in AllDocs table on a content database. SQL Server uses row locks to prevent multiple users from making conflicting modifications to table rows: when a row is locked by a user, no other users can modify it until the first user finishes modification and relinquishes the lock.

Row locks will occupy resources. If too many row locks (by default > 5000) are created, system might not sustain the overhead, and SQL Server will escalate the row locks to a single table or partition lock. Locking an AllDocs table means no user can modify content within a content database. Oops, get ready for the flooding of remedy tickets..:)

A list view is generated by a SQL Query against AllDocs table. The List View Threshold is introduced to prevent lock escalation, and it has to be <= 5000 to avoid locking AllDocs tables.

What if I need to render more than 5000 items in a list view? There are ways to do it:
          Folders are automatically indexed on creation.
          This is known as the "Happy Hours", when list view can return as many as items as users
          want, and it can be configured at the same place as list view threshold. In fact, we should
          create in index columns within "Happy Hours" since the creation process itself has to travel
          through all list items which is prevented by list view threshold.

Above is my quick review of the list view threshold. Hopefully it's helpful..:)

Leverage Web Application User Policy

Recently I had to go through a list of SharePoint sites manually to fix a Javascript issue caused by an legacy site definition.

After I was done with the first couple of sites, I realized that this could be a long boring process. All the sites reside in different site collections, and I don't have permissions to access most of them.

To grant myself as site collection administrators, I need to go to central admin > application management > Change site collection administrators, and set myself as second site collection administrator for each site collection. In that case, I would spend hours just doing clicks in central admin.







Fortunately, there is a way to grant permission to all site collections in a web application. It's called "User Policy". Under central admin > application management, pick a web application, and click "User Policy" on the ribbon, then click "Add Users".





























We can apply user policy only to certain zones of a web application, but in my case, the web application only have one "default" zone, so I left it as default value "All zones".
















Finally, I granted myself "Full Control" to the web application, and now I can access all the site collections within it.

























Essentially user policy overwrites all permission settings within a web application, so use it carefully. Once I finished my manual process, I removed the policy I added !

Monday, January 30, 2012

Enable Content Search on SharePoint 2010 My Site Top Navigation Bar

On SharePoint 2010 My Site top navigation bar, users can only do people search out of box. The OOTB My Site top navigation bar looks like:


I found out it’s actually not hard to enable content search on the top navigation bar. After adding a feature to My Site web application, the My Site top navigation bar will look like:



or




Now we can search content in All Sites scope and search people in People scope.

So how to make it happen exactly? The answer is delegate control. Delegate controls act like container controls which encapsulate default content (set of child controls inside it). The default content (set of child controls associated with delegate) can be substituted by specific controls through features. The ability to override or substitute the delegate controls brings the power & flexibility to brand SharePoint 2010 Sites.

The OOTB SharePoint Foundation marster pages define My Site top navigation bar as a delegate control with id "GlobalNavigation". We just need to create a new control and subsitute the default control with a smaller sequence number.

Let's create an empty SharePoint project deploying as a farm solution, and add a SharePoint Mapped Folder which maps to new sub folder of controltemplates folder in 14 hive. Under the new folder, we create our new control based on the default control MySiteTopNavigation.ascx under $14hive\templates\controltemplates.

We can copy MySiteTopNavigation.ascx from 14 hive controltemplates to the new mapped folder, Then swap





with










Next, add CSS style to do some makeup inside the new MySiteTopNavigation.ascx.













Next, add a empty element called "MySiteSearchDelegate", and put the following content into the Elements.xml file.








Finnally, add a feature with web application scope to deploy the element. The structure of this project would like someting like:
















After deploying the generated solution pack, and activating the feature in My Site web application, the new top navigation bar will show up....