How to replace record characters with spaces
This is a record pipeline step
The data Search.io indexes may contain characters you might not want to display on your frontend. For example, for website collections you may find that the data indexed for directory fields (
dir2) contain dashes, such as
directory-1. If you want to remove these characters (or any other characters) then you can follow these steps:
For this example we will be removing dashes
(-) from our
First navigate to Indexing > Advanced. Towards the top of the file we want to add the following steps:
- id: string-eval params: expression: constant: fields.dir1 param: bind: dir1Value - id: string-replace params: outText: bind: dir1Value replace: constant: '-: ' text: bind: dir1Value - id: set-field params: field: constant: dir1 value: bind: dir1Value condition: values.dir1Value
Let’s walk through what these steps are doing:
First we are grabbing our
dir1field and storing it to a new variable called
dir1Value. We will then use this variable in the remaining steps to store and retrieve data.
string-replacewe are stripping out
dir1Valueand replacing it with an empty space
' 'as seen in the
We are then setting out
dir1field to the value in the variable
dir1Value. For this final step, if you want to write the result to a different field, then simply replace
dir1with the field you want to write to.
Preview the changes by adding a record to the preview screen and click ‘populate’ to see if the step is working. You should see that
dir1 has the
- stripped from it 🥳 .