The input arguments that can be used when querying the Search API are discussed in this section.
Any query made using the Search API requires arguments. These include language, after, before, first, orderBy, and filter.
The after argument in the query is the cursor and is used when you want to paginate search results. The argument takes a string value, which is a base64-encoded version of the offset. In the following query, we’re getting the items after the second item by giving the after argument a value of "MQ==" (base64-encoded version of 1).
You can use the cursor field to get the cursor value for each item. To learn more about this argument as well as pagination, head to the pagination section.
This argument does the opposite of what the after argument does. It gets the values that are before the specified offset value provided to the argument. In the query below, we are getting all the items that exist before the third item by giving the argument a value of "Mg==" (base64-encoded version of 2).
This argument allows you to fetch only the amount of items you specify. Let's say you only want to grab the first three items from the search results. This is how you would do it:
To order the search results, you can use the orderBy argument. You’ll need to specify the field name and the order direction within this argument. In the following query, we are ordering by name and the direction is set to ascending.
The search results can be filtered using the filter argument. The items can be filtered using any of the following: search term, type, variants, etc. The query below filters items using the search term 'plant'.