![Magnifying Glass](https://assets-us-01.kc-usercontent.com:443/947ce730-44be-0059-7c1f-0f376607e986/bdaf066d-9ec4-4cb2-977a-1280b6e58a60/SearchStockPhoto.jpg?fm=png&auto=format&w=3840)
5 tips for Sitecore Search Development
11/06/2023
1. Know your attributes
Before doing anything, remember to review your attributes, as these are the basic building blocks of the search engine. These are located under Admin>Domain Settings>Attributes.
These will let you control the data types, required attributes, and what attributes you consider as facets or tags. Once you go and start building your extractors, you need to make sure you're providing all the required attributes and formatting all the data correctly to match the attribute's data types.
2. Use the JS document extractor
Sitecore search comes with a web crawler which is a great way to ingest data without doing any extra programming work. It allows you to crawl pages and use the data on the page to fill in attributes for the search engine to index. By default, when you create an advanced web crawler, it will start with the xpath extractor. While xpath is fine for basic metadata, the JS document extractor is much more powerful and much easier to work with.
The code actually uses cheerio syntax but should be very readable and quick to write for any front end developer. It allows you to easily find specific tags, extract data and perform basic operations, and set fallbacks easily.
A good rule of thumb is just to fill out as much of the API response as possible
3. Use the event monitor
Located under developer resources, the event monitor is the bread and butter of your coding work in Sitecore. While there is documentation for the API, the event monitor actually exposes the real responses and error messages you need for when you submit your API calls to Sitecore Search. There are actually more required fields than you would think, as the documentation does not describe them all, but the event monitor does. Without the event monitor, even an incomplete POST object might return "success" from the API, so be sure to use it.
And unlike the name implies, it also works for the Search and Recommendation API, and not just the Event API. Note that to use it, you must pass and use UUID, which you should be doing anyway in order to get full analytics and machine learning in Sitecore search.
4. Provide as much information as possible
In general, a good rule of thumb is just to fill out as much of the API response as possible. A successful post, even with no errors from the event monitor, just means you have met the minimum requirements and that the data is consumed. However, it might still mean you're missing data that the analytics reports needs inside of Sitecore Search.
The official documentation for events such as the Click Event Docs are a good starting point for showing you what you should ideally have for every event. The API documentation also describes the full object for posting.
5. Just use the SDK if you can
Points 2 and 3 were important to me because I had to actually implement the calls manually, as I was in a legacy codebase that did not use React or Next.js. Instead, I was building POST objects manually with jQuery. However, if you can use the SDK, it will handle a lot of the intricacies for you, such as building the context object and other required data that Sitecore Search needs.