October 2010 - Posts

It happens to the best of us.  Sometimes, we just need to start over.  A lot of times, I see cases in the forums where it is just easier to reinstall the Search Service Application.  This especially applies to new environments or when someone ran the dreaded “wizard” to set up their service applications.  This serves as a quick reference guide on how to re-create your Search Service Application.  When you do this, you will lose all existing search settings, your search index, your scopes, and any managed property mappings you might have made.  Keep that in mind if you are starting this procedure.

The first thing we need to do is delete the existing Search Service Application.  Typically, it is named Search Service Application.  However, if you are running FAST, it will likely be called something else.  Whatever, it is named, it will look something like you see in the picture below.  You need to select the service application to highlight it, but do not click the link.

SearchServiceApplicationSelected

Once you have selected the application, click the Delete button in the ribbon.   You will get prompted for confirmation and also with a checkbox that says Delete data associated with the Service Applications.  If you’re at the point that you need to start over, I would go ahead and check this box, since things might not work right if you don’t check it.  Click OK when to delete the service application.  It might take a few minutes to delete the application.

SearchServiceApplicationDeleteConfirmation

Your Search Service Application along with its proxy is now gone.  Now, we need to create a new one.  On the Service Applications page, click the New button in the ribbon.

NewSearchServiceApplication

On the next screen, you will be asked for a service application name, whether or not its associated with FAST, and what the application pool settings are.  To keep things consistent, I usually use the name Search Service Application.  If you don’t have FAST, just leave the Fast Service Application set to None.  If you do have FAST, you’ll need to look up all your settings and follow the FAST documentation before you can proceed.  I would recommend you create a new account for your Search Service Account if you haven’t already.   If you used the configuration wizard earlier, the application pool that was used previously is SharePoint Web Services Default and the account it uses is your farm account.  You can continue to use that if you wish.  However, this is a great opportunity to create new application pools and register a separate account.

NewSearchServiceApplicationDetails

Once you have configured all settings, click the OK button and you will see a progress screen that will take several minutes.

NewSearchServiceApplicationProgress

Once it finishes, you can click on the Search Service Application to begin configuration.  When you look at the status, it will still be provisioning things to your farm for several minutes.  You might see something like this.

NewSearchServiceApplicationNewlyProvisioned

Note that the Propagation Status reports Waiting for initialization.  You may get some errors during this phase as things aren’t quite up and running yet.  The first thing you want to do is change the Default content access account.  I have posted on this before.  You need to change it to an account that is not a service account, farm account, or administrator account.  If you don’t you’ll have issues with security trimming.  The next thing you might want to do is modify your farm topology to add index partitions, set up mirroring, or redundant indexers.  I’ll talk more about search farm topology in a future article.

At this point, you need to set up your content sources again and start crawling.  You can do this through the UI, however, I recommend using PowerShell.  By using PowerShell, it will make it easier to move these settings to other farms in the future (i.e.: test and staging).  You can use PowerShell to create new content sources (post coming), set up managed properties, and set up scopes.  The Local SharePoint Sites content source should be configured automatically to crawl you SharePoint sites, so just verify the settings and kick off a full crawl.  This is a good time to set up your crawl schedule again.  Once the crawl is finished, you should be able to start executing queries.  Go to your search center (or create a new one) and test things out.

This last weekend, I had the opportunity to speak at the Tyson Developer Conference as well as the NWA CodeCamp the following day.  I spoke about how easy it is for an ASP.NET developer to get started with SharePoint 2010 development.  I had a good time at the conference and enjoyed meeting a lot of new people.  My slides have been posted on Slide Share.  Please, let me know if you have any questions.  Thanks.

SharePoint 2010 Development for ASP.NET Developers

When you install SharePoint and configure your Search Service Application, it usually does a pretty good job making sure that your default content access (aka crawl) account has the appropriate permissions to your SharePoint sites.  However, many times, it is necessary to adjust permissions to get this to work.  This could be caused by you simply wanting to change the account that is used or because it is not working for some reason.  For today’s post, we’re specifically talking about setting permissions so that your content access account can properly crawl your SharePoint web applications.  I will also remind you that you never want to use an account with administrator privileges for your crawl account.  If you do, you will have issues with security trimming.

First, verify that the account you are using for crawling is the one you want.  You can view this in the Search Service Application under Default content access account.  You can change your account here if necessary.  Otherwise, just make a note of it.

SearchCrawlAccount

Once you know what account you are dealing with, we can go set the permissions on your web application.  Go back to Central Administration and then click on Manage Web Applications.  Next, you want to select the web application that needs permissions.  Highlight the web application you want and then click the User Policy button.

WebApplications

In this popup, you want to verify that your default content access account is listed.  If you see it there, make sure it has Full Read permissions and nothing else.  If it is not there, click the Add Users button to add your content access account.  On the first step, you will want to pick (All Zones) and then click Next.  On the next screen, enter your account name, choose Full Read and use the default settings for all other options.  Once you are done, your accounts should look something like this.

WebApplicationUserPolicy

Once you are happy with your accounts, click OK.  You then want to go back to the content sources page in your Search Service Application and perform a full crawl.   Performing the full crawl will ensure that security trimming is properly applied when users search your SharePoint site. 

I had a great time at Houston TechFest this weekend.  I met a lot of new people and I got to see a lot of old friends.  At TechFest, I spoke about how to code advanced SharePoint BCS solutions using BCS entity models and custom connectors.  The slide deck is posted on slide share.  I’ve also attached the code for the custom connector I used at the bottom of this post.  If you have any additional questions, feel free to ask.

I absolutely love the new social ratings site columns that we can easily add to existing SharePoint 2010 document libraries.  It gives such an easy way for end users to rate documents in an interface they are probably already familiar with because of iTunes.

DocumentLibrarySocialRatings

I got to thinking.  Seeing these social ratings in my search results sure would be useful.  It would also be nice to be able to query them.  How do we do that?  We use managed properties of course.  I did some digging and found out that there isn’t a managed property already out there for this so we need to create one.  We know the actual name of the site column is AverageRating (the display name is Rating (0-5)).  This means that once we have performed a crawl, we should have a crawled property called ows_AverageRating.  Sure enough if you look in your crawled properties, it is there.  In my screenshot below, you see the result of me mapping it later.  Yours shouldn’t have anything listed under Mapped To yet.

AverageRatingCrawledProperty

Create a new managed property called AverageRating (or whatever you want to call it).  Choose a data type of Decimal and pick the ows_AverageRating column from the list. 

AverageRatingManagedProperty

Now you need to go back to your content sources page and do a full crawl.  When your crawl completes, we can now test and see if our new property works.  Go to your Search Center and try the query below.

AverageRating>=3

If all goes well, you should see some search results for documents that have more at least three stars.  Note that there are no spaces in that query at all.  If it doesn’t work, you may not have any documents rated yet or you recently applied ratings and you need to wait for the timer job to run.

This tells us that we can write queries on our managed property, but we want to actually see them in our results as well.  For this we need to customize the properties we return in search results as well as the XSLT.  We can do this in either CoreResutlsWebPart or on the Local Search Results federated location.  I am going to edit the federated location.  Go down to Core Search Results Display Metadata under Display Information and edit the Properties.  Start by adding the following inside the Columns element.

<Column Name="AverageRating" />

This tells Enterprise Search to include this column in the results.

AverageRatingFederatedLocation

We then need to edit the XSL.  Finding the right spot can be somewhat tricky, but it’s not too difficult.  A good spot for your new rating is in the srch-Metadata2 div.  This is where it already displays things like author, file size, and tags.  Simply add the following right before the blank.gif reference.

Rating: <xsl:value-of select="averagerating"/>

It should look like this when you’re done.

AverageRatingXSL

When you finish editing your XSL, save your changes, wait a minute or so and then go and try your query again.  You should now see search results similar to the ones below.  Notice the Rating listed for each result.

AverageRatingSearchResults

This gives us a decent representation of what we can do with social ratings in search results.   Wouldn’t it be nice if we could sort by this new managed property?   Sorry, you’ve got to buy FAST for that or write your own search results screen using the QueryManager class.  Even without sorting though, i think this adds a lot of value to your search results.

The next step would be to display actual stars instead of a numerical representation.  I’ll continue to work on something on how to do that.  In the mean time, someone smarter than me at XSL may be able to provide us all an answer. :)  If you have one, I’d love to see it.