Elasticsearch Search Highlights, Conditional visibility settings for form elements - This week in Orchard (18/04/2025)

This time, you can see a fascinating demo about the conditional visibility settings for form elements! But first, let's take a look at our other topics, like adding Search Highlights to Elasticsearch queries!

Orchard Core updates

OrchardHelper content APIs should be accessible without namespace

In previous versions, you needed to use the OrchardCore namespace in Razor pages or views to access the content helpers provided by IOrchardHelper. This is unlike other services, which can be accessed directly without needing the namespace. Starting with Orchard Core v.3, we have removed the need to use the OrchardCore namespace in Razor pages or views to access the content helpers. You can now access the content helpers directly, without needing to use the OrchardCore namespace. Note that the ContentRazorHelperExtensions has been replaced by ContentOrchardHelperExtensions.

OrchardHelper content APIs should be accessible without namespace

Elasticsearch Search Highlights

Orchard Core v.3 introduces support for Search Highlights in Elasticsearch queries. When highlights are enabled, Elasticsearch returns relevant text segments that match the search term, providing a more contextual and user-friendly display of search results.

With this feature, Elasticsearch will return highlighted fragments wrapped in custom HTML tags, which can then be displayed in the Search module or other components. This enables the presentation of more relevant content that directly matches the search term. Don't forget that highlights request only work when the content item is stored in the Elasticsearch service.

To check this out, ensure you are using an Elasticsearch cloud service or have deployed it with Docker. Refer to this documentation for the details.

The following example demonstrates how Elasticsearch can be configured to return highlighted text within search results. In this query, the highlight section specifies how matched terms will be wrapped in HTML tags with a yellow background, and it limits the highlighted fragments to 1 with a maximum size of 250 characters each.

Elasticsearch query

On the screen below, you can see the search results with and without Highlights.

Search result with and without Highlights

Demos

Conditional visibility settings for form elements

This addition aims to build a decision tree that leads users down a specific path to obtaining our desired answers.

In this demo, you can see a form for the Halls Creek Tree company that allows us to take orders from users without needing a complex setup. Let's start with the front-end! So, you asked a question for a list of items. We are looking for the Redbud tree, which is 4 inches in size, and the flowers are red. Depending on the options given, you can steer users in one direction. Finally, you can submit your order. By clicking the Submit button, you can start a workflow and create a content item based on the form.

Form on the front end

Now, let's take a look at the admin UI! Here we have a content item with the Flow Part attached, where you can find the input fields. Every input field has a tab near the Content one, called Visibility Settings. Under that tab, you can specify the action to take when the condition is met. The default action is Always Visible, but you can select to Conditionally Show or Conditionally Hide. After the action, you can set the groups that can contain rules. Each group can have multiple rules, and the UI will change accordingly based on the operators and values we select.

Visibility settings

And that's not all about this feature! Check out this recording to learn more about how to steer users down using a decision tree based on their input or choices!

News from the community

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 455 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.

Do you know of other Orchard enthusiasts who would like to read our weekly articles? Tell them to subscribe here!

If you are interested in more news about Orchard and the details of the topics above, don't forget to check out the recording of this Orchard meeting!