|
| 1 | +[role="xpack"] |
| 2 | +[testenv="basic"] |
| 3 | +[[uri-parts-processor]] |
| 4 | +=== URI parts processor |
| 5 | +++++ |
| 6 | +<titleabbrev>URI Parts</titleabbrev> |
| 7 | +++++ |
| 8 | + |
| 9 | +Parses a Uniform Resource Identifier (URI) string and extracts its components as |
| 10 | +an object. This URI object includes properties for the URI's domain, path, fragment, |
| 11 | +port, query, scheme, user info, username, and password. |
| 12 | + |
| 13 | +[[uri-parts-options]] |
| 14 | +.URI Parts Options |
| 15 | +[options="header"] |
| 16 | +|====== |
| 17 | +| Name | Required | Default | Description |
| 18 | +| `field` | yes | - | Field containing the URI string. |
| 19 | +| `target_field` | no | `url` | Output field for the URI object. |
| 20 | +| `keep_original` | no | true | If `true`, the processor copies the |
| 21 | +unparsed URI to `<target_field>.original`. |
| 22 | +| `remove_if_successful` | no | false | If `true`, the processor removes |
| 23 | +the `field` after parsing the URI string. If parsing fails, the processor does not |
| 24 | +remove the `field`. |
| 25 | + |
| 26 | +include::common-options.asciidoc[] |
| 27 | +|====== |
| 28 | + |
| 29 | +Here is an example definition of the URI parts processor: |
| 30 | + |
| 31 | +[source,js] |
| 32 | +-------------------------------------------------- |
| 33 | +{ |
| 34 | + "description" : "...", |
| 35 | + "processors" : [ |
| 36 | + { |
| 37 | + "uri_parts": { |
| 38 | + "field": "input_field", |
| 39 | + "target_field": "url", |
| 40 | + "keep_original": true, |
| 41 | + "remove_if_successful": false |
| 42 | + } |
| 43 | + } |
| 44 | + ] |
| 45 | +} |
| 46 | +-------------------------------------------------- |
| 47 | +// NOTCONSOLE |
| 48 | + |
| 49 | +When the above processor executes on the following document: |
| 50 | + |
| 51 | +[source,js] |
| 52 | +-------------------------------------------------- |
| 53 | +{ |
| 54 | + "_source": { |
| 55 | + "input_field": "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment" |
| 56 | + } |
| 57 | +} |
| 58 | +-------------------------------------------------- |
| 59 | +// NOTCONSOLE |
| 60 | + |
| 61 | +It produces this result: |
| 62 | + |
| 63 | +[source,js] |
| 64 | +-------------------------------------------------- |
| 65 | +"_source" : { |
| 66 | + "input_field" : "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment", |
| 67 | + "url" : { |
| 68 | + "path" : "/foo.gif", |
| 69 | + "fragment" : "fragment", |
| 70 | + "extension" : "gif", |
| 71 | + "password" : "mypassword", |
| 72 | + "original" : "http://myusername:mypassword@www.example.com:80/foo.gif?key1=val1&key2=val2#fragment", |
| 73 | + "scheme" : "http", |
| 74 | + "port" : 80, |
| 75 | + "user_info" : "myusername:mypassword", |
| 76 | + "domain" : "www.example.com", |
| 77 | + "query" : "key1=val1&key2=val2", |
| 78 | + "username" : "myusername" |
| 79 | + } |
| 80 | +} |
| 81 | +-------------------------------------------------- |
| 82 | +// NOTCONSOLE |
0 commit comments