Skip to main content


SharePoint Online – When to use Content Search vs Content Query

Some of you may be doing a double take. Wait, is this post really about the Content By Query Web Part? Didn’t that die with the release of the Content By Search Web Part? In short, no! There are a few use cases where the Content By Query web part is still very useful – and necessary!!
What is the Content By Query Web Part?cbq1
First introduced in SharePoint Server 2007, the Content By Query (CBQ) web part allows you to display data from multiple lists in one web part. Going back to SharePoint Portal Server 2001, there was no mechanism to collate information together from various lists and libraries. There were List View Web Parts, but those only displayed information from a singular list. When Microsoft released the CBQ web part, it was revolutionary to the platform. It introduced the ability to style and customize the web part via XSLT – that the time, the latest and greatest technology. For more information, please see this MSDN article.
What is the Content By Search Web Part?
First introduced in SharePoint 2013, the Content By Search Web Part (CSWP) enables the new SharePoint Search Driven Architectures – meaning this web part displays information from the Search Index. The CSWP also displays results in a way that you can easily format. A new feature called Display Templates are used to style the results of a CSWP. Display templates are snippets of HTML and JavaScript that render the information returned by SharePoint. The information to be displayed gets inserted into the page in JSON format. There is also a wonderful GUI for building and configuring the CSWP. The query engine is extremely powerful, allows for almost any customization, and is extremely user friendly – no code knowledge required. The GUI will also show the results of the query so you can preview the data and ensure it’s getting pulled correctly.
When to use Content By Search or Content By Query?
The CSWP can return any content from the search index. Use it on your SharePoint 2013 sites when you are connecting to a search service and want to return indexed search results in your pages. The CSWP returns content that is as fresh as the latest crawl of your content, so if you crawl often, the content that the CSWP returns is more up-to-date than if you crawl infrequently.
**If you need to display instant content or the refreshed version of content, use the CBQ instead.**
Search crawls only the major versions of content, never the minor versions. If you want to display the minor versions of your content, do that by using a CBQ.
Some site collection administrators mark sites to not be indexed. Content marked in this way is not available in a CSWP. If you want to return results from a site that is marked to not index, use the CBQ instead.
**Use the CSWP when you want to display information from another site collection. The CBQ cannot query data across a site collection boundary**
SharePoint Online Search Crawls
In SharePoint Online, Microsoft controls all Search Crawl scheduling and execution. There is literally zero visibility into this process. According to KB 2008449

Search crawls occur continuously to make sure that content changes are available through search results as soon as possible. Recently uploaded documents may not immediately be displayed in search results because of the time that’s required to process them. SharePoint Online targets between 15 minutes and an hour for the time between upload and availability in search results (also known as index freshness). In cases of heavy environment use, this time can increase to six hours.

Yes, you read that correctly – “In cases of heavy environment use, this time can increase to six hours.”
This means that when deciding when to use the Content By Search Web Part vs the Content By Query Web Part, you must consider the amount of time you are willing to wait in order for your content to appear in the web part.
What does this all mean?
Using the Content By Search web part in all scenarios simply isn’t feasible. Ensure that your business requirements are fully documented and planned before any implementation decisions are made. It is important that your business users are consulted in this process. Some organizations are firmly entrenched in a Just-In-Time mentality; meaning when they want a change, they want it now! And that’s ok, thankfully we still have the option of using the old Content By Query web part.
In my next post, I’ll go through an example of customizing the Content By Query web part in SharePoint Online. Stay tuned!

Thoughts on “SharePoint Online – When to use Content Search vs Content Query”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Joe Crabtree

More from this Author

Follow Us