10 search commands you need to know to find anything in SharePoint
One of the common complaints from users after they have migrated content to SharePoint/Teams/OneDrive is that it is impossible to find the content they are looking for. Search results are sometimes too generic, and unless the users know the exact location where content results, they just do not appear in search. So with this article, I wanted to share some search commands/techniques with you to improve your search experience and findability of content. The tips below are not listed in any particular order and are listed in the order they came to my mind as I was writing this blog post.
SharePoint Search Out of the box
The primary reason for writing this blog post was the fact that SharePoint search is a pretty powerful feature. When you type something in the search box, it searches the following:
- File Name
- Folder Name
- Content of the documents
- Metadata associated with the documents
On one hand – it is a blessing; on another, it is a curse. It is not uncommon to have hundreds of thousands of documents, even for a small business. So finding a single document out of the pool of all the content is like trying to find a needle in a haystack. In order to do so, you need to employ some specific techniques/search commands that will complement the search keyword. And this is exactly what I am pleased to document for you below.
10 search commands you need to know to find anything in SharePoint
Tip # 1. Search just the contents of the document
As mentioned above, mighty SharePoint search searches everything: file name, contents of the file, metadata, and even folder names. Many times though, you just want to find a document that contains a specific keyword.
To limit the search scope and only find the documents that contain the specific keyword, you need to use the body:keyword in the search box. I explained this feature in this article.
For example, if you type in the body:accounting it will only find documents that contain the keyword “accounting” inside the documents and will ignore the same keyword in a file or folder name.
Tip # 2. Combine search keywords using Boolean operators
Sometimes you might be looking for not one, but multiple keywords when you search for documents. In this case, you can use Boolean operators like AND, OR, and NOT to include or exclude specific keywords. I explained it in greater detail in this article.
For example, I am looking for a document that contains the keywords RED and BLUE. In this case, I will type the following into the search box: red AND blue.
Tip # 3. Exclude keywords by using the minus sign
Sometimes you want to do the opposite and exclude specific keywords from search results. In this case, you can just put a minus sign before a keyword you want to exclude. For example, below, I have a library of company policies (8 policies total).
When I type in the keyword “vehicle” into the search box, it shows me documents containing the word “vehicle” either in the file name or inside the document. Out of 8 documents, there are only two that match this query.
However, if I want to do the opposite and do not want to see documents containing this keyword, my query would be “-vehicle.” As a result, it will show me the other 6 files in the document library.
Tip # 4. Search for the exact phrase by adding double quotes
When you type keywords into the search box, the search turns up results that match any of the keywords or their combination. However, many times you need to find the exact phrase within a document. For this, you need to include double quotes around the keywords.
For example, when I type the following phrase into the Search box: ABC Company Equipment, it shows results that match any of the keywords mentioned.
However, when I enclose the same keywords string in double quotes: “ABC Company Equipment”, I get a document that contains the exact phrase.
Screenshot of a PDF document that contains the exact phrase found by SharePoint Search
Tip # 5. Wildcard search
Many times, you need to find variations of a certain keyword. Say, you have a number of legal documents and need to find one that contains some person’s last name, but you do not remember the exact spelling. In this case, you can use a few letters you know, followed by an asterisk “*”. It will turn up all the search results that match this criteria. Very important to note is that you can only use wild card search at the end of the keyword, not in the front!
Tip # 6. Exclude documents/files from search results
While your most frequent searches in SharePoint will be around documents, there are occasions when you want to exclude documents from the search results. Say, for example, you want to find all results that match the keyword “budget”, but you do not want to see any files/documents that match this keyword; you just want to see results from pages, lists, links, etc.
By default, when you type in the keyword, it shows you every type of content that matches the keyword.
However, you can also exclude the documents by using a simple command: “-isdocument:true”. The “-“ sign from Tip # 3 I shared above, excludes any results that are files/documents.
Tip # 7. Search files by their size
Another cool trick is the ability to search files of a certain size. For example, the use case could be when you need to find files larger than 1 GB. You would need to use size managed property inside the SharePoint search box. I explained how this trick works and its nuances in this article.
Tip # 8. Search file name only
Another trick worth sharing – sometimes you might remember the file name and do not want the search to show any other contents that match the keyword (i.e., contents of the file, pages, etc.). In this case, you would use Keyword Query Language (KQL) and use the following command: filename:keyword. For example: filename:Fraud Policy
Tip # 9. Search content types
This next trick is only valid if your organization has embraced metadata and content types. If so, you use another KQL trick and search for specific Content Types using the SPContentType command. For example: SPContentType:Invoice
Tip # 10. Search for files tagged with specific Managed Metadata
Another trick if your organization is using metadata. Not just any metadata, but the one defined in the Term Store. We also call it Managed Metadata. If you need to find all documents/content tagged with a term from within the Term Store, simply type in the tags command. For example: tags:budget.
Other tips to improve search
Know the location where to search
Another way to improve search would be to know the exact place where to execute a search in SharePoint. There are different levels that exist where you can search (all of them documented here), and you will get different results depending on the search scope (locations where you are searching):
- Library Level
- Site Level
- Hub Level
- SharePoint Start Page or SharePoint Home
Training
It kind of relates to everything mentioned in this article – none of those tips & tricks make sense unless you educate your audience on such capabilities. Again, your users need to understand what I mentioned above about different search results/locations. And they need to understand at least some of the possibilities mentioned above as well. Not to mention other generic capabilities and nuances of SharePoint Online. You probably know from my blogs already that I am a huge fan of training, so I definitely recommend that you do not ignore it.