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 (dir1, dir2) contain dashes, such as directory-1 or 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 dir1 field.

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
CODE

Let’s walk through what these steps are doing:

  1. First we are grabbing our dir1 field and storing it to a new variable called dir1Value. We will then use this variable in the remaining steps to store and retrieve data.

  2. Now using string-replace we are stripping out - from dir1Value and replacing it with an empty space ' ' as seen in the replace parameter.

  3. We are then setting out dir1 field 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 dir1 with 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 🥳 .