Starting a new project on XM Cloud? Here are some considerations for content search.
The new composable, headless architecture of Sitecore has many benefits, I think we all agree. But there are features that we’ve taken for granted for a long time on Sitecore XM that won’t be immediately available on XM Cloud. One of the big gaps I can see is content search.
Experience Edge
If you’re looking at a new XM Cloud site today, you might be looking at initially leveraging the search features of Experience Edge. Let’s review the search features:
- Search by field name and string value matches by a list of supported operators
- Comparison operators: EQ, CONTAINS, NEQ, NCONTAINS
- Flexibility around grouping field search predicate with “AND”, “OR”
- Order by fieldname ascending or descending
- Pagination
At first look, seems pretty good right? I do love the flexibility around the search predicates. But when I think back few the last few projects I’ve done, I also needed the following features:
- Keyword / phrase search across multiple fields including datasources
- More comparison operators: LT (less than), GT, LTE, GTE
- Date comparison support
- Integer comparison support
- Decimal comparison support
- Coordinate filtering (Latitude / Longitude / Radius)
- Faceting support
- Template inheritence filter (filter by items that inherit from a template)
- Site context filter (filter by a root item / site context)
- Ability to differentiate between Solr Search and Solr Filter queries
With the above features, we are pretty close to a truly powerful search that would handle most requirements. The other “nice to haves” that I could think of are:
- Personalised results based on previous searches
- AI / ML / fuzzy matching on keyword / phrase search to give that really “Google-like” user experience
Can Experience Edge deliver on the above requirements? No. Hence we need to look at alternatives.
Sitecore Authoring GraphQL API
In Sitecore 10.3 and XM Cloud, there is the new Sitecore Authoring and Management GraphQL API. This has a search endpoint which isn’t based on the Experience Edge schema, but there are some similarities. Most importantly it does fill some of the above requirements:
- Ability to differentiate between Solr Search and Solr Filter queries
- Boosting
- Faceting
- Query Operators: Should, Must, Not
- Comparison Operators: Exact, StartsWith, Contains, EndsWith, Wildcard, Search, Range, Fuzzy, Proximity, RegExp
- Advanced sorting
The namespace to closely investigate the schema is Sitecore.GraphQL.Services.Abstractions.Model.Searching.SearchQuery
.
It’s still missing keyword / phrase search and coordinate search.
Because this API is not going to be surfaced via Experience Edge as far as I know, it isn’t ideal to use for Content Delivery purposes on XM Cloud, but it could be viable for use on Platform DXP (OnPrem / PaaS) hosted solutions.
Sitecore Search
Sitecore Search is a new next-gen search product that is coming out soon. It’s a rewrite of the OrderCloud Discover product to support both order search and content search capability.
The architecture diagram would look something like this:
There isn’t much information available on it at the moment, but reviewing our list above, it ticks a lot of boxes.
A couple that it doesn’t tick (based on my limited knowledge, and from reviewing the currently available Discover documentation)
- No coordinate filtering
- Template inheritence and some of the more advanced field comparison / search predicate handling
Okay, but the other issue is it’s not actually out yet. So what else?
SearchStax SearchStudio
SearchStax SearchStudio is an offering which ticks a lot of the boxes above. The API doc isn’t very clear, but it looks like it works by letting you build up what is basically your own Solr query. That will, of course, be good in that you can do whatever you want, but it doesn’t provide a good developer experience. If you’re writing your front-end in Next.js, you don’t want to be hand-crafting complex Solr queries!
Any other options?
Coveo Headless and Algolia are worth a look at, I haven’t done an in-depth comparison or analysis though. If you have, please get in touch with me so I can add here whether they tick some of the above boxes.
What about building it yourself?
In Sitecore XM, I did build it myself by extending the Sitecore XM Experience Edge GraphQL Preview endpoint, and adding all of those features discussed previously (excluding the “nice to haves”). It worked well and has been a great success, but unfortunately that isn’t possible in XM Cloud.
You could consider getting your own SolrCloud or ElasticSearch instance, building an indexer that indexes the content on your CM, and then building an API for the front-end that converts GraphQL queries into Solr / Elastic queries.
I hope this helps on your composable journey!