Some handy keywords you might find useful in SharePoint Enterprise Search
Thursday, August 12, 2010
Enterprise Search is one of my favorite SharePoint topics to speak about. Often in my talks, I use various keyword queries to display results that people often end up asking me about. Today, I thought it would be useful to show you some of the most useful built-in keywords that you can use to troubleshoot search results or even build custom scopes with. I see people post in the forums all the time about how to do many of the queries I have in the list below, so I figure this is will be a good post to refer people to. You can use pretty much all of these with SharePoint 2010 or MOSS 2007 right out of the box (once you crawl).
The ContentSource keyword is incredibly powerful. You can use it to verify that results exists for a given content source. For example, if you were having issue crawling a file share and you wanted to see if any results were present or not, you could use this keyword. Start by identifying the content source in question on your content sources page in your Search Service Application.
Note the spelling of your content source exactly. If I wanted to return everything from the file share, I would issue this query.
On my server I get results like this.
Keep in mind that you can combine these keywords with other ones. For example if I only want accounting documents on the file share, it would look like this.
Accounting ContentSource:"File Share"
To query all documents on the SharePoint site itself, you could use a query against the Local SharePoint Sites (Local Office SharePoint Sites on MOSS 2007) content source. Be warned that this could return a large number of results.
ContentSource:”Local SharePoint Sites”
Another property, more people are more familiar with is IsDocument. This handy property is a great way to filter out items that are not documents (i.e.: folders, list items, and pages). You pass a value of 1 for true. In the example below, I return all documents on my SharePoint server.
If you have spent time building custom scopes, you might be interested in the Scope keyword. This makes it easy to query everything in your scope at once. You can use this to build advanced queries or just for simple troubleshooting of the scope. In this example, I have a scope with rules only to show items from a BCS content source with a property called Color set to red.
A lot of times people ask questions about how to just show results for a given site or site collection. Maybe even a specific document library. You can do that with contextual search, but you can also do that with the Site keyword as well. Simply pass it the URL to the specific point on your site and it will filter the results. For example, if I just want to see results from my ECM subsite, I would use the following query.
Sometimes you might want to see all documents a particular user modified. The author keyword is a great way to find things when you want to see all documents from someone that recently left the company. For example, to see all of the documents by our fictitious CFO, Christina Murphy, we would use this query.
If you know you only want to see documents of a certain content type, why not query for it? You can with the ContentType keyword. For example to search all documents of my custom type called Custom Document, I would use the following query.
You can also write queries based on list template such as a document library, task list, or your own custom list template with the ContentClass keyword. Simply use any known content class with the keyword (here is a list). For example, to search only items in a task list, I would issue the following query.
Want to see a query that only has Excel spreadsheets? No problem. Use the FileType keyword. Don’t include the period on the extension. You can use multiple FileType keywords together to span multiple types (i.e.: xlsx and xls).
The last keyword I will cover is Write. You use it to query documents based on modification date. You can’t take full advantage of this keyword in MOSS 2007, but in SharePoint 2010, you can do some cool things by using the new operators >,<,>=,<=. This allows you to write queries to see all documents written since the beginning of the month for example. Your date should be in quotes and make sure there is no space between the keyword and the date itself.
These are all keyword I use on a regular basis. Remember you can combine most of these together to provide vary narrow search results. You could also make use of these by writing your own advanced search control. I hope these queries are useful the next time you use Enterprise Search. If you can think of any other good ones I left out, please leave a comment.
NOTE: This post is also available at www.DotNetMafia.com.