Files
honeymoose f321dfedf5 同步完成!
**同步结果摘要**:

| 目录 | 同步前 | 同步后 | 官方 |
|------|--------|--------|------|
| aggregations | 40 | 65 | 64 |
| analyzers | 8 | 141 | 140 |
| api-reference | 97 | 186 | 174 |
| benchmark | 34 | 67 | 53 |
| clients | 17 | 18 | 18 |
| dashboards | 38 | 149 | 131 |
| data-prepper | 77 | 134 | 123 |
| im-plugin | 22 | 37 | 37 |
| ingest-pipelines | 27 | 52 | 51 |
| install-and-configure | 37 | 57 | 53 |
| ml-commons-plugin | 81 | 157 | 155 |
| observing-your-data | 39 | 73 | 66 |
| query-dsl | 40 | 77 | 75 |
| search-plugins | 80 | 139 | 95 |
| security-analytics | 22 | 47 | 46 |

**说明**:
- 本地文件数 > 官方:本地有一些官方已删除或重命名的文件
- 新增了约 **740 个英文文档文件**
- 已有文件保持不变(未覆盖)
2026-11-30 10:48:30 -05:00

3.0 KiB

layout, title, parent, grand_parent, nav_order
layout title parent grand_parent nav_order
default substringAfter() Functions Pipelines 60

substringAfter() function

The substringAfter() function is used to extract the portion of a string that follows the first occurrence of a specified delimiter. It takes two arguments:

  1. The first argument is either a literal string or a JSON pointer that represents the source string.

  2. The second argument is the delimiter string to search for within the first argument.

If the delimiter is found, the function returns the portion of the string after the first occurrence of the delimiter. If the delimiter is not found, the original string is returned. If the source resolves to null, the function returns null. If the delimiter is null or empty, the original string is returned.

For example, to extract the value after the first occurrence of the = character in a field named header, use the substringAfter() function as follows:

'substringAfter(/header, "=")'

{% include copy.html %}

If /header contains Content-Type=application/json, the function returns application/json.

Alternatively, you can use a literal string as the first argument:

'substringAfter("hello-world-foo", "-")'

{% include copy.html %}

The function returns world-foo because it extracts the portion of the string after the first - character.

The substringAfter() function performs a case-sensitive search. {: .note}

Example

The following pipeline uses the substringAfter() function to extract the domain name from an email address field. It adds the extracted domain name as a new field called domain:

substring-after-demo:
  source:
    http:
      ssl: false

  processor:
    - add_entries:
        entries:
          - key: domain
            value_expression: 'substringAfter(/email, "@")'

  sink:
    - opensearch:
        hosts: ["https://opensearch:9200"]
        insecure: true
        username: admin
        password: "<custom-admin-password>"
        index_type: custom
        index: demo-index-%{yyyy.MM.dd}

{% include copy.html %}

You can test the pipeline using the following command:

curl -sS -X POST "http://localhost:2021/log/ingest" \
  -H "Content-Type: application/json" \
  -d '[
        {"email":"[email protected]"},
        {"email":"[email protected]"}
      ]'

{% include copy.html %}

The documents stored in OpenSearch contain the following information:

{
  ...
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "demo-index-2026.03.13",
        "_id": "abc123",
        "_score": 1,
        "_source": {
          "email": "[email protected]",
          "domain": "example.com"
        }
      },
      {
        "_index": "demo-index-2026.03.13",
        "_id": "def456",
        "_score": 1,
        "_source": {
          "email": "[email protected]",
          "domain": "opensearch.org"
        }
      }
    ]
  }
}