Skip to content

Commit 6418f59

Browse files
authored
Merge pull request #45 from chrschw/specialchars
TASK: Add hint about replacing special chars to docs
2 parents f7e3aba + b360766 commit 6418f59

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,16 @@ The plugin comes with a controller that can be reached like this per default, us
105105
It expects the search term as a parameter named `q` (as defined in `AjaxSearch.fusion`). This controller
106106
renders the search results and returns them as HTML without any of the page template. It can therefore
107107
be used to request search results via AJAX and display the result by adding it to the DOM as needed.
108+
109+
## Removing special chars from search term
110+
111+
You might need to remove special chars to prevent search errors. Some chars are reserved in Elasticsearch
112+
and you can replace them before submitting the search like this:
113+
114+
prototype(Flowpack.SearchPlugin:Search) {
115+
searchTerm = ${request.arguments.search}
116+
searchTerm.@process.removeSpecialChars = ${String.pregReplace(value, "/[^a-zA-Z0-9äöüÄÖÜß]/", "")}
117+
}
118+
119+
Keep in mind, that this blocks the explicit use of wildcards (`*`) and phrase search (`"search exactly this"`)
120+
for your users, in case you want to support that.

0 commit comments

Comments
 (0)