Archive for the 'Search' Category

Content Classes and Search

So I was playing with SharePoint search a while back, and I was wanting to display some results differently based upon what type of item the result was for.

It turns out that there is a node in the results xml file that shows this - ContentClass :

Results XML showing ContentClass

As you can see, the first highlighted result is STS_ListItem_DocumentLibrary. Pretty clear what that is. Not all results actually have a content class - the second highlighted result is from a document on a file share, and it doesn’t have a ContentClass.

So what content classes are there? Well, Dan Attis has a good list, along with a caveat about Welcome pages in the results. There is a similar list here. (Nobody mentions not having a ContentClass though). But unfortunately, I don’t know how to add new content classes

How do I get rid of the Action Links on my Search Results Page?

I wanted to get rid of the Action Links on a standard Search Results page in SharePoint:

Standard Search Results Action Links

So I opened up my search page in SharePoint Designer. This always looks a bit cluttered, but I went to my Core Search Results Web Part to modify it’s ShowActionLinks property.

SharePoint Designer view of Results page, showing that ShowActionLinks is already False

I’ve scribbled on this to highlight the obvious web parts on the page. The Core Results web part is highlighted in cyan. Anyway, if you look at the code in the top of the screenshot you can see that the ShowActionLinks setting is already False. Eh? Read more »

Saving SharePoint Searches

One of my colleagues was asking how to save a SharePoint Search. It’s a bit of a question of how many ways to skin a cat…

The important thing to remember is that a simple search is just a URL, and specifies the search term and scope in the k and s parameters respectively. E.g. This search url:

http://deltamoss01/searchcenter/Pages/Results.aspx?k=Badgers&s=All%20Sites

would run a search for badgers in the All Sites scope.

It is worth noting, however, that this is saving the search, not a set of search results. As the index is updated, the results on this page may vary. Also, advanced searches don’t pass their parameters as GET parameters (i.e. within the URL), so you can’t save these the same way. I’ve not yet found a way to save them.

As another note, the standard Search results page shows the ‘Alert Me’ link:

The Alert Me Link

This lets you set up email alerts about new items that match a search:

Alert Me Configuration Page

Really, that’s pretty neat. Read more »

Advanced Search - Losing Parameters

I have a bit of a problem with Advanced Search in SharePoint - it’s very awkward to use.

When I perform a standard search in SharePoint, it shows me what I’ve been searching for:

Search Results showing Search Term of Snake

That’s good - it’s useful to know what you’ve searched for. If I then click on ‘Advanced’ the advanced search page opens showing my search term, and a number of other fields I can fill in for a more specific search.

Advanced Search Screen with Search term of Snake

If I then run that search, though, I get the following results page:

Search results, but with no apparent search term

Okay, now that is a little odd looking. There is no search term in the search input box. This is perhaps not surprising - the advanced search screen can express more complex queries than the text input box of the simple search control. However, there is nothing to tell you what the results are of. You have no idea what the search was that gave these results!

Worse happens if you try to go back to your advanced search page. Unless you use the browser’s Back button, you will lose your current query. There is no obvious way of ‘refining’ an advanced query.

It looks like this is happening because the simple Search box passes it’s parameters in the URL as GET parameters, but the Advance Search page uses a postback-then-forward approach.

Is it too much to ask for to have a web part that describes what the conditions of an advanced search are, and to store that query to pass back to the Advanced Search page, should the user wish to refine their query.

SharePoint Search doesn’t have Wildcard searching

Yesterday I described Search Stemming and how to set it up. I thought I’d have a look at Wildcard searching and discovered (to my shock) SharePoint Search doesn’t have general wildcard searching.

This isn’t news - the normally evangalistic Patrick Tisseghem posted about this a year and a half ago, and plenty of folks have expressed their surprise at this. I can’t say I blame them. There are third party products that given general wildcard searching, but I’ve not see or used any of them, and some of them get mixed reviews.

You might have noticed that I spoke specifically about general wildcard searching. Well, you can do wildcard searching when you’re search for a property of a particular value. For example, a search for Title:Water would return results about water, waterloo, watergate, watering, Muddy Waters, etc.. Perhaps a comparison would be useful to make things clearer. Read more »

Search Stemming in SharePoint

So, my playing with search recently has shown that the search stemming in SharePoint is turned off by default. Search stemming is what takes a search term like ‘Fill‘ and also matches against ‘Filling‘ and ‘Filled‘. This is different to wildcards - ‘Fill*‘ would also match words like ‘Fillet‘. Here is an example of searching for Apple and Apples without stemming… Read more »

Create an Image only Search Scope in Sharepoint

Previously I’d looked at having a search that shows thumbnails of images in SharePoint. I modified the results page to do this - but the results themselves would still show non-Picture items (e.g. documents, pages, etc.). In this post, I’ll configure up a new Search Scope for images only. Read more »

Showing Thumbnails in Search

One of my colleagues was asking about building a search which would show thumbnails for images, and whether that was possible. I decided to try a 5 minute prototype, so I took a copy of the results.aspx page in my Search Center, and started hacking…

I have a Picture library with some images in it (they’re pinched from Flickr, so sorry for the copyright thing to their respective owners - but they’re lovely looking test data). You might notice that the images in the pictures Library are already thumbnailed:

Picture Library with Sample pictures

Firstly, I took a look at all the xml I was getting back from the search results. (You can add to that.)

Search results XML

Great! So I’m getting the thumbnail for the picture through in the search results, and I can also identify what pictures are by the ContentClass. Nice one!

Normal Results pages XSL

The first thing I noticed on opening up the XSL for the normal results page was that there is a section about showing a thumbnail. Normal search results don’t show a thumbnail though - so what gives?

Well, there are a few conditions before it’ll show the thumbnails - the ContentClass of the result (which is okay), the presence of a thumbnail URL, and the variable $IsThisListScope being true. I’m not sure what the $IsThisListScope variable is for, but I decided to delete it from the condition. As the other parts are met the results should show thumbnails for items which have them (i.e. Pictures).

Redesigned XSL

And if I perform a search for, say, balloons, then I get some results with thumbnails:

Results page showing Thumbnails.

Now, it’s worth noting, this page will still show non-pictures results - just my results didn’t have any. The next step would be to create a scope to only include images.

The curious incident of the date column in the night-time

I have been tearing my hair out over a problem with dates and timezones. We have a site column ‘Document Date’ that we are using in our search results page. It only holds a date.

Our client noticed that some dates appeared on the search results page as a day earlier than the value in the lists themselves. For example, the list would show a document date of the 8th of May, but the search results would show the 7th of May. Curious, and the start of a bit of a detective story… Read more »

Hit Highlighting in SharePoint Search Document Titles

I came across an interesting behaviour in a search results page I’ve been working on. I’d added some code to do search highlighting on the results of a query. Here’s an example of the results I got for a search for ‘Barnacles’:

Search Results showing Hit Highlighting in the Titles and Description of documents

The observant amongst you will notice that the titles all contain the word ‘Barnacles’, but only some are highlighted - specifically where the word barnacles is not the last word before the dot-extension of the file name. I did some further testing and found that the search does recognise the word ‘Barnacles’ in the file name, but the hit highlighting doesn’t seem to. Read more »

Next Page »