Introduction


In previous articles, we've shown you how you can use the parameters use_search and use_adv_search for different purposes.

  • WebApp Search on the Front End - use_search - Allows the keyword`parameter in the URL. Using this parameter, the WebApp will search all its fields for matches of this key word. 
  • Advanced WebApp Search on the Front End - use_adv_search - Allows you to specify one or more fields in the database - the WebApp or Module with the use_adv_search parameter set will then filter its results to only show items where all of these filters are true. (It uses AND logic.)

It's actually possible to set both of these parameters, if you want to give the User a choice about how they want to find content. However, the User will only be able to use one of them at a time.

Syntax


You can add both types of search parameter when including a WebApp or Module:

{%- include 'module', id: '12', layout: 'design_system/1', per_page: 2, show_pagination: 'false', use_adv_search: 'true', use_search: 'true' -%}


For examples of how to build HTML and JavaScript controls for re-assigning the URL with different query parameters- check out these Articles:

Examples

In these examples, we'll show how the syntax above will provide different results as we change the parameters in the URL.

Now, here's my example output with no parameters:

With both Liquid parameters set, what effect does the keyword URL parameter have on the results?

Here's what happens when I set the URL to search by keyword: /filtered-events-map?keyword=New 

You can see that only the "New Year's Day" Event is displayed.

With both Liquid parameters set, what effect does the category URL parameter have on the results?

If I set the URL to filter by a field /filtered-events-map?category=235 (using use_adv_search ) instead, I'll be able to fetch a result which matches.

Using both keyword and field search together- using AND Logic


However, if you want to both search with a keyword and filter by the Category field at the same time, this will only be able to do so with AND logic. You won't be able to use OR logic to find Items which meet one but not the other condition.

The following URL will fetch an Item, because I have one which meets both conditions: /filtered-events-map?category=235&keyword=Tour

However, I won't be able to find that item if I change the filtering to only show results with a different Category ID: /filtered-events-map?category=234&keyword=Tour. There are no items which match both conditions:

Related Articles


Using these two features together is powerful, but if you want even more options and features, building your own GraphQL queries will take your Site to the next level:


If you missed the original articles on the use_search and use_adv_search features, you can find them here:

Did this answer your question?