Skip to content
On this page

How to configure the site's suggest

Plumbsearch allows users to customize site suggestions using a JSON array. Each suggestion can be configured with a specific data processing type, which is specified using the type parameter. Here are the possible types:

request:get

Sends a GET request to a URL specified by the url_pattern parameter. The {key} parameter in the URL will be replaced with the user's input. Example:

json
{
    "type": "request:get",
    "url_pattern": "https://www.iconfinder.com/ajax/autocomplete?q={key}"
}

request:post

Similar to the usage of request:get. Sends a POST request to a URL specified by the url_pattern parameter. The {key} parameter in the URL will be replaced with the user's input.

re:match

Processes the data using a regular expression specified by the pattern parameter. Example:

json
{
    "type": "re:match",
    "pattern": "json\\((.+)\\)$"
}

This example will match data in the format json(...) and return the contents inside the parentheses as an array.

jsonpath

Processes the data using JSONPath expressions. The path parameter specifies the JSONPath expression. Example:

json
{
    "type": "jsonpath",
    "path": "$.aa[*].value"
}

Such as using the above departure:

input: {"aa": [{"value": 0}, {"value": 1}, {"value": 2}, {"value": 3}, {"value": 4}]}
output: [0,1,2,3,4]

You can use online tools like https://jsonpath.com/ to test your JSONPath expressions.


Finally, you need to process the requested data into an array of strings, and the Plumbsearch plugin will automatically load and display it to the user, making it easy for them to search.