1 / 5

The Ultimate Guide to Passing Query Parameters in the Search Blueprint

Learn how to pass query parameters in the Search Blueprint to customize your search results. This guide covers everything you need to know, from the basics of query parameters to advanced techniques.

inextures
Download Presentation

The Ultimate Guide to Passing Query Parameters in the Search Blueprint

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Ultimate Guide to Passing Query Parameters in the Search Blueprint In this documentation, we will explain how we are fetching the query parameter from the request to add the value to the custom parameter of the search context, which is accessible in the condition values of our sample search blueprint. Below are the steps we have taken to achieve this: • We have created a sample blueprint. In this blueprint, we have created a parameter in the parameter configuration, and the value of this parameter is compared to the query's condition.

  2. •Below is the condition that we are comparing for the custom parameter in our sample blueprint. • To create this parameter and pass its value to the blueprint, we have overridden PortletSharedSearchContributor by creating my custom module CustomBlueprintParameterContributorPortletSharedSearchContributor • We have added a condition to pass the custom.orderBy parameter from this module in the searchContext object on the basis of the query parameter value. The added code snippet: ThemeDisplay themeDisplay = portletSharedSearchSettings.getThemeDisplay(); if(themeDisplay.getRequest().getParameter("orderBy") != null) { if (themeDisplay.getRequest().getParameter("orderBy").equals("newest")) { searchRequestBuilder.withSearchContext( searchContext -> { searchContext.setAttribute( "custom.orderBy", "newest"); } ); } if (themeDisplay.getRequest().getParameter("orderBy").equals("oldest")) {

  3. searchRequestBuilder.withSearchContext( searchContext -> { searchContext.setAttribute( "custom.orderBy", "oldest"); } ); } } Integrate the custom portlet into the search page where you want to apply the search changes • Select the blueprint in which we are passing the custom parameter

  4. When we are passing the query parameter orderBy as newest it is compared in the blueprint and gives the desired result. OrElse passing the query parameter orderBy as oldest gives the desired effect as given in the sample blueprint. After completing these steps, we have achieved the following result:

  5. Conclusion In this blog, we have provided a comprehensive guide on passing query parameters in the search blueprint. We can dynamically adjust the search results based on the query parameter values by leveraging custom parameters and condition values in the blueprint. Overall, this guide empowers developers to effectively pass query parameters into the search blueprint, enabling greater flexibility and control over the search results presented to users. Originally published by: The Ultimate Guide to Passing Query Parameters in the Search Blueprint

More Related