Dot Peekser Logo

#Configuration#Customization

Mastering Sitecore Search: Configuring Indexed Content and Customizing Search Results

by Fabian Holtermann on

Note: This blog post is a follow-up to our previous Sitecore Search Introduction article. It is recommended to read the introduction post first, as it provides essential foundational knowledge for understanding the concepts discussed here.

https://dotpeekser.de/posts/introducing-sitecore-search

Introduction

Welcome back to our Sitecore Search series! In our previous blog post, we introduced you to the powerful capabilities of Sitecore Search and explored how to set up indexing for your website. Today, we're taking a deeper dive into Sitecore Search as we explore how to view and adjust the indexed content and configure search results to meet your specific needs.

Viewing Indexed Content

After setting up indexing, it's crucial to review the indexed content and make necessary adjustments to ensure its accuracy and completeness. To begin, head over to the Catalog/Content section, where you'll find all the indexed content conveniently listed.

As you explore the indexed content, you may notice that the current setup does not include images. Don't worry, we can rectify this by examining the available attributes and making adjustments to the document extractor responsible for indexing.

Navigate to the Administration/Domain Settings/Attributes page, where you'll find a comprehensive list of attributes. Each attribute has specific properties that define how the content is indexed. In this case, we are particularly interested in adding images to our search results.

Locate the default attribute image_url, which we can utilize to incorporate images into our indexed content. To modify the document extractor and include this attribute, navigate to Sources/[source name]/Document Extractors/[extractor name].

Now, let's make the necessary adjustment to the code. Within the tagger function, add the following line:

[javascript]: Extractor Configuration
'image_url': $('meta[property="og:image"]').attr('content'),

This line instructs the document extractor to extract the image URL from the og:image meta tag on each page. By incorporating this line, we ensure that the image URL is included in the indexed content. After saving the changes and publishing them, we must wait for the crawler to run again, updating the indexed content with the newly added images.

Return to the Catalog/Content area to examine the indexed content once more. You should now see preview images associated with each entry, providing a visually enriched search experience.

Configuring Search Results

In this section, we will focus on configuring search results to meet specific requirements and deliver a tailored search experience. By creating a search page and widget, you can fine-tune the display of search results based on your desired criteria.

01 Creating a Widget

To get started, we need to create a new widget for our page. Widgets allow us to define rules that modify the results displayed or hide certain results altogether. Let's navigate to the widgets area and click the "+ Add Widget" button to create a new widget.

In the widget creation process, choose "search results" as the widget type and provide a meaningful name for identification. For now, let's name our variation "Default" since we won't be conducting A/B testing. Ensure that you select the "Page" option for the "used in" setting.

Don't forget to publish the widget, as it is crucial for it to be visible and accessible for selection on our page.

02 Create a Page

With the widget created, let's move on to the "Pages" section and create a new page. Fill in all the required fields, following a straightforward process. Once you have completed the page creation, navigate to the default variation of your newly created page.

In the default variation, you can select the previously created widget. Note that each page can have multiple widgets, but for the sake of simplicity, we are focusing on a single widget in this example. While it's possible to create a new widget directly from the page, it's generally recommended to navigate to the widget section first to maintain better overview and organization.

After publishing the newly created page, you can utilize the Sitecore Search API to search for content. However, in our next blog post, we will delve deeper into leveraging the API and explore more advanced search capabilities.

03 Configure Search Results

Now, let's return to the widget and explore the available configuration options. Select your widget and the "Default" variation created a few moments ago. You will be presented with an empty page where you can find the "+ Add Rule" button. Clicking on this button will open the "Rule Editor" where we can define various aspects of the search results.

On the left-hand side of the Rule Editor, you will notice three tabs:

  1. "Context"
  2. "Strategy"
  3. "Settings."

The "Context" tab allows us to define under which circumstances the results will be shown based on specific conditions or criteria. For example, you can configure the context to act only when a particular keyword is entered in the search.

The "Strategy" tab enables us to manipulate the order of the search results. It provides a user-friendly WYSIWYG (What You See Is What You Get) editor, allowing you to easily customize the order and prioritize specific content.

Lastly, the "Settings" tab allows for overriding global settings specific to the widget. In most cases, these settings may not require any modification.

04 Create a rule to pin content

Let's create a simple example to illustrate the widget configuration. Suppose we want to prioritize a specific content item and ensure it appears at the top of the search results whenever a visitor searches for "Sitecore Search". To achieve this, navigate to the "Context" tab and create a new "Context Attribute". Select "Keywords" from the dropdown menu, specify "Sitecore Search" in the empty text field, and remember to save your changes.

Next, switch to the "Strategy" tab and arrange the search results to feature the desired content at the top. If the content is already visible, simply drag and drop it to the desired position. If not, use the search feature on the right-hand side to locate and drag the content into the desired order.

By following these steps, we have successfully created our first widget configuration. We have defined that if a visitor searches for "Sitecore Search", the specified content will always appear at the top of the search results.

Conclusion

In conclusion, configuring search results empowers you to tailor the search experience according to your specific requirements. By creating widgets, defining rules, and prioritizing content, you can enhance the relevancy and display of search results. In our next blog post, we will explore advanced techniques using the Sitecore Search API to create dynamic and powerful search widgets for your website, application, or intranet.

Stay tuned for the upcoming article, where we'll delve deeper into the Sitecore Search API and its capabilities.

Fabian Holtermann

For over 14 years, I've been dedicated to crafting web experiences that make a real impact. I thrive on continuously improving my skills and embracing new challenges that come my way.