Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] URI parts processor #65695

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/reference/ingest/ingest-node.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -900,4 +900,5 @@ include::processors/split.asciidoc[]
include::processors/trim.asciidoc[]
include::processors/uppercase.asciidoc[]
include::processors/url-decode.asciidoc[]
include::processors/uri-parts.asciidoc[]
include::processors/user-agent.asciidoc[]
85 changes: 85 additions & 0 deletions docs/reference/ingest/processors/uri-parts.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[role="xpack"]
[testenv="basic"]
[[uri-parts-processor]]
=== URI parts processor
++++
<titleabbrev>URI Parts</titleabbrev>
++++

The URI parts processor parses a text field containing a Uniform Resource
Identifier (URI) and writes its components to the specified field.
Components that may be extracted from the URI include domain, path, fragment,
port, query, scheme, user info, username, and password.
danhermann marked this conversation as resolved.
Show resolved Hide resolved

[[uri-parts-options]]
.URI Parts Options
[options="header"]
|======
| Name | Required | Default | Description
| `field` | yes | - | The field in the input document
containing text that may be parsed as a URI.
danhermann marked this conversation as resolved.
Show resolved Hide resolved
| `target_field` | no | `url` | Field under which the components
of the parsed URI should be written.
danhermann marked this conversation as resolved.
Show resolved Hide resolved
| `keep_original` | no | true | If true, the unparsed contents of
`field` will be copied to `<target_field>.original`.
danhermann marked this conversation as resolved.
Show resolved Hide resolved
| `remove_if_successful` | no | false | If `true` and the processor
successfully parses the contents of `field` as a URI, then `field` will be
removed from the document.
danhermann marked this conversation as resolved.
Show resolved Hide resolved

include::common-options.asciidoc[]
|======

Here is an example definition of the URI parts processor:

[source,js]
--------------------------------------------------
{
"description" : "...",
"processors" : [
{
"uri_parts": {
"field": "input_field",
"target_field": "url",
"keep_original": true,
"remove_if_successful": false
}
}
]
}
--------------------------------------------------
// NOTCONSOLE

When the above processor executes on the following document:

[source,js]
--------------------------------------------------
{
"_source": {
"input_field": "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment"
}
}
--------------------------------------------------
// NOTCONSOLE

It produces this result:

[source,js]
--------------------------------------------------
"_source" : {
"input_field" : "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment",
"url" : {
"path" : "/foo.gif",
"fragment" : "fragment",
"extension" : "gif",
"password" : "mypassword",
"original" : "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment",
"scheme" : "http",
"port" : 80,
"user_info" : "myusername:mypassword",
"domain" : "www.example.com",
"query" : "key1=val1&key2=val2",
"username" : "myusername"
}
}
--------------------------------------------------
// NOTCONSOLE